Cannot read property 'addEventListener' of undefined in AWS CHIME - node.js

I am trying to run the AWS CHIME demo project locally. it is working fine if I doesn't change the const host ="127.0.0.1:8080" in the server.js file. But when changing the host to local IP to virtualization of host it throws an error after
the error showed to me
Unable to find meeting
There was an issue finding that meeting.
The meeting may have already ended, or your authorization may have expired.
Cannot read property 'addEventListener' of undefined

Related

Timeout when communicating with Web3 Provider

Background
I am trying to investigate and solve problems with a containerized NodeJS web service app that communicates with Avalanche Test Network (https://api.avax-test.network/ext/bc/C/rpc) in order to Mint NFTs.
//...
provider = new HDWalletProvider({
privateKeys: [walletPrivateKey],
providerOrUrl: "https://api.avax-test.network/ext/bc/C/rpc",
pollingInterval: 4000,
});
const myContract = Contract(Contract_NFT);
myContract.setProvider(provider);
const _instance = await myContract.at(process.env.CONTRACT_NFT_ADDRESS);
_instance.mint(provider.getAddress(), mintURL, { from: provider.getAddress() })
//...
Note: I am not the developer of app.
Issue
After starting the container, first request completes successfully. However subsequent requests fail with code: -32603 message: 'ETIMEDOUT' error
at new NodeError (node:internal/errors:387:5)
at Web3ProviderEngine.emit (node:events:502:17)
at /app/node_modules/web3-provider-engine/index.js:54:14
at afterRequest (/app/node_modules/web3-provider-engine/index.js:148:21)
at /app/node_modules/web3-provider-engine/index.js:174:21
at /app/node_modules/web3-provider-engine/index.js:232:9
at /app/node_modules/async/internal/once.js:12:16
at replenish (/app/node_modules/async/internal/eachOfLimit.js:61:25)
at /app/node_modules/async/internal/eachOfLimit.js:71:9
at eachLimit (/app/node_modules/async/eachLimit.js:43:36)
at /app/node_modules/async/internal/doLimit.js:9:16
at end (/app/node_modules/web3-provider-engine/index.js:211:5)
at Request._callback (/app/node_modules/web3-provider-engine/subproviders/rpc.js:36:21)
at self.callback (/app/node_modules/request/request.js:185:22)
at Request.emit (node:events:513:28)
at Timeout.<anonymous> (/app/node_modules/request/request.js:851:16)
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
undefined
at PollingBlockTracker._performSync (/app/node_modules/eth-block-tracker/src/polling.js:51:24)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
When the app is used outside a container and directly on server OS, all requests successfully complete.
What I have tried
I tried searching the internet forums and boards. Similar issue is mentioned in some posts but suggested solution is to tweak Timeout/Interval values which did not help with my issue and still got the error.
I tried using the same NodeJS and NPM versions installed on server OS. Also tried using different versions of NodeJS( 14.XX, 16.XX). Still got the same error.
Also I have tried changing and configuring Docker network( different type of network driver, different IPAM config, passing extra hosts etc.). Still got the same error.
I have confirmed that mentioned URL is accessible from inside container using ping, nc and dig tools. Also have confirmed that successful HTTPS connection is being established.
Questions
What is causing this behavior?
What I can do to reliably use this app inside container?
Have I missed something?

problem running simple demo example google-maps-services-js with Node

I have a problem running this simple demo example for google-maps-service with Node:
https://github.com/jpoehnelt/google-maps-services-js-demo
I am not sure what I am missing. When I run npm start, I get this error:
TypeError: Cannot read property 'elevation' of undefined
at D:\node_practice\google-maps-services-js-demo\index.js:14:35
at processTicksAndRejections (internal/process/task_queues.js:97:5)
I am using nvm and my node version is 13.9.0. I tried it on two different machines (one windows with above node version, one ubuntu) and both got the same error.
it seems the response coming back is empty. your r.data is empty, which means results[0] is undefined, so is the reason you are getting Cannot read property 'elevation' of undefined.
Below is the actual exception coming back from the APIs
"You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account"
Get the instruction of getting an API key from here https://developers.google.com/maps/documentation/directions/get-api-key
and use the same with your code.

Google Cloud API Environment Credentials on Node.js on Phusion Passenger server

I have the translation client library set up on my Windows home Node.js server and use set GOOGLE_APPLICATION_CREDENTIALS=[PATH] to instantiate the credentials when I start the machine. This works fine.
On the publicly hosted server I don't think the request gets as far as asking for credentials because a different error is thrown than the one saying The request is missing a valid API key. This would appear I forgot to set the credentials or defined the path incorrectly.
I've tried many variations of export GOOGLE_APPLICATION_CREDENTIALS="[PATH]" but the error I keep getting is:
UnhandledPromiseRejectionWarning: Error: Unexpected error determining execution environment: Unsuccessful response status code. Request failed with status code 404
at GoogleAuth.<anonymous> (/usr/home/.../public_nodejs/node_modules/google-auth-library/build/src/auth/googleauth.js:163:23)
at Generator.throw (<anonymous>)
at rejected (/usr/home/.../public_nodejs/node_modules/google-auth-library/build/src/auth/googleauth.js:20:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
I think this is to do with setting the environment variable in Phusion Passenger, but it's odd to me that the error I get is different.

AWS Request Expired Error

I'm trying to execute a script in which an AWS security group is created using NodeJS. When I try and run the script I get an error saying:
Error { RequestExpired: Request has expired.
Has anyone seen this? What does it mean? I thought the time between my local machine and the AWS Host might be off so I set a new timezone in my script to make up for the difference but still same error.

Using Google CloudSQL, getting "connect ECONNREFUSED 127.0.0.1:3306"

I'm trying my best to learn Google's Cloud Platform. They have a CloudSQL offering, which I'm learning via this NodeJS tutorial. Everything worked great until I deployed to their appspot server, at which point I got the following error:
connect ECONNREFUSED 127.0.0.1:3306
I've looked all through the NodeJS project and don't see anything in it or the Cloud Console that is referencing localhost or 127.0.0.1. Googling the error hasn't helped thus far. Any ideas?
I couldn't get this thing fixed when running on server but using this files I was able to read/write from local and production, now im using this connection strings in my own app
https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql
https://github.com/GoogleCloudPlatform/nodejs-docs-samples/tree/master/appengine/cloudsql
I had a similar issue when deploying the nodejs sample app 2-structured-data
The reason why the error occurred is that the NODE_ENV environment variable was not passed to the config file that is used to check if node should use a socket for connecting to mysql
You can fix it by adding 'NODE_ENV' in the file config.js :
.env([
...
'NODE_ENV'])

Resources