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?
Related
i'm using Firebase version 9 (MODULAR) as database for a web application in nodejs v18.
When i try to access data from localhost i get the error below, but from an heroku deployment works like a charm.
[2022-06-26T07:32:22.447Z] #firebase/firestore: Firestore (9.8.4): Connection GRPC stream error. Code: 7 Message: 7 PERMISSION_DENIED: Permission denied on resource project "my_project",.
[2022-06-26T07:32:22.447Z] #firebase/firestore: Firestore (9.8.4): Could not reach Cloud Firestore backend. Connection failed 1 times. Most recent error: FirebaseError: [code=permission-denied]: 7 PERMISSION_DENIED: Permission denied on resource project "my_project",.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
[2022-06-26T07:32:22.466Z] #firebase/firestore: Firestore (9.8.4): Connection GRPC stream error. Code: 7 Message: 7 PERMISSION_DENIED: Permission denied on resource project "my_project",.
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
[FirebaseError: Failed to get document because the client is offline.] {
code: 'unavailable',
customData: undefined,
toString: [Function (anonymous)]
}
Node.js v18.0.0
For context:
the web app its an internal tool so i do my own authentication server-side and then the app makes some checks on some data on the firestore db. So basically who makes the queries its the app,not the user. This makes me thing that i should use a service account with firestore-admin api.
The problem is that the provided code snippet from the docs,does not work for me..
var admin = require("firebase-admin");
var serviceAccount = require("path/to/serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
And i already changed the access rule to be the horribly unsecure one:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
Any idea on what i should do? Or maybe why it doesnt work on local development?
Since the documentation it an incomplete maze of stuff i am probably missing something..
Thanks to anyone that can help! (at least to understand why)
As the GitHub link suggests, the issue might be due to useFetchStreams being enabled by default, in the new modular build (v9).
Hence, modify your code accordingly:
import {initializeFirestore} from 'firebase/firestore'
const db = initializeFirestore(firebaseApp, {useFetchStreams: false})
Also, the error might arouse not because the android device or emulator you are debugging is offline but because the "databaseURL" setting was missing in the part that defines the Firebase configuration object. I think that the same error might occur if the setting is incorrect.
Also, I suggest you have a look at this Stackoverflow case, which talks in detail about all the probable reasons behind the ‘Client is offline’ issue.
However, if the above solution does not, suggest you enable debug logging by calling setLogLevel.
firebase.firestore.setLogLevel('debug');
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
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.
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.
Im working on getting node-xmpp working with a jabber server we have in house here. I was able to get it working with talk.google.com just fine, and i can connect to our internal server with adium or ichat just fine.
Node v0.6.14
CentOS 6.2 / 2.6.32
node-xmpp 0.3.2
OpenSSL 1.0.0
connect code
var j = new xmpp.Client({
jid : 'user#domain',
password : 'pass',
host : 'chat.domain'
});
After tracing through the code, it seems it gets stuck right after it tries to upgrade the connection to a secure connection. This occurs in starttls.js in the starttls function.
The pair.on('secure') event is never called, and even after i print out pair after a settimeout, its still not appearing to be authorized. At this point i dont see any data in or out.
After a long time sitting there (several minites) it prints out an error that looks like this
throw arguments[1]; // Unhandled 'error' event
^
Error: 139644497663968:error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error:s23_clnt.c:674:
at CleartextStream._pusher (tls.js:508:24)
at CleartextStream._push (tls.js:334:25)
at SecurePair.cycle (tls.js:734:20)
at EncryptedStream.write (tls.js:130:13)
at Socket.ondata (stream.js:38:26)
at Socket.emit (events.js:67:17)
at TCP.onread (net.js:367:14)
The server is using a self signed cert if that matters.
Any ideas?
Thanks!
This looks like you're sending a TLS handshake when the server isn't expecting it, so the server isn't sending its handshake back.
One possibility is that you're talking old-style TLS (handshake-first) to a server that implements start-TLS. In your real code, are you setting the legacySSL parameter? Are you sure you're talking to an XMPP server on the target box?
A wireshark trace would give us the data to be able to tell for sure.
I was experiencing the same issue: connection hangs while trying to perform a TLS handshake with one particular Openfire XMPP server installation (though others worked fine).
After nearly losing my mind, I ended up modifying starttls.js that ships with node-xmpp to use tls.connect() and forcing SSLv3 and to my surprise it worked.
Gist here: https://gist.github.com/jamescoletti/6591173
Hope this is useful to someone.