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

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.

Related

"Error: Internal error encountered" while running RequestSync to Google Homegraph API - Node.js

I am using a Nodejs client to integrate with Google Smart Home.
When I request to RequestSync API, it sometimes shows the following error.
Error: Internal error encountered.
Although I saw the above error, it seems that the SYNC request has been triggered properly.
Does anyone know why this happens?
Since the request failed and returned an error, our app retries the RequestSync again and again, so I'd like to fix the error if possible.
Thank you.
Environment
#googleapis/homegraph: 3.0.2
Nodejs: 18.4.0

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?

Cannot read property 'addEventListener' of undefined in AWS CHIME

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

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.

Uncaught (in promise): Response with status: 0 in Angular2/Ionic2

I have linked my app into NodeJS server, after the get request goes(sucsses) I get an error on the app Uncaught (in promise): Response with status: 0 for URL: null.
This is the lastest branch of the app:
https://github.com/eshk12/Parabi/tree/DB-LINKED
And this is the NodeJS server:
https://github.com/eshk12/parabiNodeJS
I am talking about the function CreateMedicine() inside /Services/NetworkServices.ts.
The function CreateMedicine() goes to http://localhost:3000/Medicines/add/ with its GET parameters and insert them to the database.
but unknown error appear.
Hope you guys may help me fix it.
Thanks!
I believe that happens when the OPTIONS call fails. Most likely due to the service being unavailable.
OPTIONS http://localhost/api/login net::ERR_CONNECTION_REFUSED

Resources