How can I resolve, if EAI_AGAIN error happens on facebook messenger platform? - node.js

Our Node.js app for facebook messenger platform threw the following error.
We use "request" module to connect to facebook graph api and the module threw this error. And the problem was resolved without doing anything about 1 hour after I found the problem. So now it's working, but I'm afraid when it'll happen again. Could you teach me this problem and if there is any resolution?
{ Error: getaddrinfo EAI_AGAIN graph.facebook.com:443
at Object.exports._errnoException (util.js:949:11)
at errnoException (dns.js:33:15)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
code: 'EAI_AGAIN',
errno: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: 'graph.facebook.com',
host: 'graph.facebook.com',
port: 443 }

Short answer:
This happens when you have lost connection to your DNS server or the DNS settings are wrong (this includes, but is not limited to, complete or partial disconnect from internet).
That is: Please check if your cable or WiFi connection OR your internet provider does not have a (temporary) problem.
Details:
When this happened, I could see in the debugger call stack that the system function getaddrinfo fails. Thus, it seemed like the trivial reason was - the system cannot map the host name to an IP (in your case the host name 'graph.facebook.com" could not be found).
Indeed, when I tried to ping the host name, which I wanted to reach I got the same as ping error like pinging an unknown host:
u#h:~$ ping someunknownhost.xyzdomain
ping: unknown host someunknownhost.xyzdomain
Additionally when, my connectivity to internet recovered and I could ping the host then the problem of node.js also disappeared.

Related

heroku postgres ETIMEDOUT when conencting through localhost

I have a website which uses the free tier of heroku postgres I was running it on localhost and it was working just fine till today no changes were made to the code and the database url and everything is just fine
Error: connect ETIMEDOUT 3.224.164.189:5432
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1246:16) {
errno: -4039,
code: 'ETIMEDOUT',
syscall: 'connect',
address: '3.224.164.189',
port: 5432
}
This is the error which I get and this error is only shown on localhost, when the same code is deployed to heroku, it works just fine
Also, one thing which I've noticed is that it works just fine when I use my mobile network and this issue only occurs when I use my ethernet connection.
Can Someone help me out with this sticky situation?

Issue in GCP : getaddrinfo ENOTFOUND issue in Google Cloud Platform

Getting Error: getaddrinfo ENOTFOUND for external API call.
I have shifted some of my company's infra to GCP. The issue I am facing is that suddenly out of the blue our GCP instances which are behind a VPC are giving us error
Error: getaddrinfo ENOTFOUND somedomain.xyz.in
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26) {
errno: 'ENOTFOUND',
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'somedomain.xyz.in'
This error suddenly pops up and goes away automatically after sometime.
Sometimes through one instance I am able to ping the above mentioned DNS whereas sometimes the SAME DNS is not ping-able from same instance. I have my billing etc all enabled. If someone has any solution please let me know.
Couple of more details :
I am using Ubuntu18.04 LTS
Instance on GCP are running a NODEJS program which pings the above mentioned external IP using HTTPS.
The external service to which our system pings is hosted on Digital Ocean and is on Public IP and is mapped to a DNS.
The call is made using needle package of NPM.

NetworkingError: getaddrinfo EMFILE dynamodb.eu-west-1.amazonaws.com:443

There is a table say company. If we try to get the company by it primary key we get the following error.
PLEASE NOTE: This error is not for all instances. It is not repeatedly getting failed. It occurs sometimes but often. 20% of requests are failing
{ Error: getaddrinfo EMFILE dynamodb.eu-west-1.amazonaws.com:443
at Object._errnoException (util.js:1022:11)
at errnoException (dns.js:55:15)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
message: 'getaddrinfo EMFILE dynamodb.eu-west-1.amazonaws.com:443',
code: 'NetworkingError',
errno: 'EMFILE',
syscall: 'getaddrinfo',
hostname: 'dynamodb.eu-west-1.amazonaws.com',
host: 'dynamodb.eu-west-1.amazonaws.com',
port: 443,
region: 'eu-west-1',
retryable: true,
time: 2019-07-18T05:30:09.145Z }
There was a discussion on aws/aws-sdk-js-v3 with issue #3019 where it was recommended to lower the socket timeouts.
This happened to me too when I used the agent as below
new https.Agent({
keepAlive: true,
maxSockets: Infinity,
}
Then I looked more into the documentation here at Reusing Connections with Keep-Alive in Node.js and what I found was an interesting thing
The easiest way to configure SDK for JavaScript to reuse TCP connections is to set the AWS_NODEJS_CONNECTION_REUSE_ENABLED environment variable to 1. This feature was added in the 2.463.0 release.
So, I removed the httpsAgent from the AWS DynamoDBClient connection and added the required environment variable -
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
The error was resolved and things were working as expected.
I hope somebody might find this answer helpful.

Remote access to IIS-express

Usually when I start my web application, the browser will open https://localhost:44305
But I want to reach the site from my phone. I've tried changing the applicationhost configfile, firewall inbound rules and all that. But then I found this little thing iisexpress-github
I type this in my console: iisexpress-proxy https://localhost:44305 to 3005
Which results in this line: Proxying https://localhost:44305 to network interfaces:
Ethernet: 192.168.10.41:3005
Listening... [press Control-C to exit]
After following instructions, the browser gives following error: 'Aw snap! Something went wrong. Check your console to see the error.'
And then I look at my console which says the following:
Error: unable to verify the first certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1016:38)
at emitNone (events.js:67:13)
at TLSSocket.emit (events.js:166:7)
at TLSSocket._finishInit (_tls_wrap.js:585:8)
Usually my site is https, but this seems only to proxy to normal http.
What to do?

NodeJS ExpressJS ETIMEDOUT net.js

came in on Monday morning and my node app is not working. No code changes have occurred recently. Users are receiving this error when trying to connect:
Error: connect ETIMEDOUT
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
Seems like something must have changed on the server, although I'm yet to figure out what it is. There was a power outage over the weekend. Any insights as to what would cause this? I receive the same error if I try to connect to my node app on the server itself, so it seems it can't be firewall related.
In case it's helpful to anyone else, the problem was that my backend database services had not restarted after the power outage. Not sure why this was the error thrown, but that's what solved it for me!

Resources