NodeJS errno 37 on socket.connect - node.js

I'm trying to connect to multiple hosts in succession, this is the code to resolve the ip address and socket.connect() to each domain name (line[1]). This works on it's own but returns an errno 37 error when run in quick succession with different hosts. The best information I have on the error is:
" code: 'EPROTO', description: 'protocol error' "
Code:
$.connect(port, line[1], function() {
this.write(request);
});
Error:
{ [Error: connect Unknown system errno 37]
code: 'Unknown system errno 37',
errno: 'Unknown system errno 37',
syscall: 'connect' }
How can I resolve this / why is this happening?
Thanks in advance.
EDIT: removed manual dns lookup code and added error report

duplicate with https://stackoverflow.com/questions/14672743/nodejs-crash-when-calling-socket-connect-in-quick-succession
Seems to me opening sockets in rapid succession is asking for trouble.
Try waiting in between opening the sockets and play with the amount of time needed to wait.

Related

SQLITE_IOEERR: in Meteor

Retrying after error { [Error: SQLITE_IOERR: disk I/O error] errno: 10, code:
'SQLITE_IOERR' }
Retrying after error { [Error: SQLITE_IOERR: disk I/O error] errno: 10, code:
'SQLITE_IOERR' }
/home/kdibbs/.meteor/packages/meteor-tool/.1.4.2.1r0536n++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:190
throw error;
^
Error: SQLITE_IOERR: disk I/O error
at Error (native)
=> awaited here:
at Promise.await (/home/kdibbs/.meteor/packages/meteor-tool/.1.4.2.1r0536n++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:39:12)
at Db._execute (/tools/packaging/catalog/catalog-remote.js:355:8)
at /tools/packaging/catalog/catalog-remote.js:144:10
at Db._retry (/tools/packaging/catalog/catalog-remote.js:156:16)
at new Db (/tools/packaging/catalog/catalog-remote.js:143:8)
at RemoteCatalog.initialize (/tools/packaging/catalog/catalog-remote.js:694:15)
at /tools/cli/main.js:815:20
So I ran this meteor program a few days ago, then I made a few more users and a group on my machine..All of which didn't affect my normal user...And now I'm getting this error? Any clues?
Thanks.
Did you try searching for this? Looking at the SQLite reference here https://www.sqlite.org/rescode.html#ioerr
It sounds like one of your disks is giving an error - something like too many files open, or perhaps it's getting full?
(10) SQLITE_IOERR
The SQLITE_IOERR result code says that the operation could not finish
because the operating system reported an I/O error. A full disk drive
will normally give an SQLITE_FULL error rather than an SQLITE_IOERR
error.
There are many different extended result codes for I/O errors that
identify the specific I/O operation that failed.

How can I resolve, if EAI_AGAIN error happens on facebook messenger platform?

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.

EMFILE, too many open file

[INFO] system - { codeblock: 'catch copy image', error: { [Error: EMFILE, too many open files './uploads/54f911bad366ed/document/document_559dfb750f15617.png']
errno: 20,
code: 'EMFILE',
path: './uploads/54f911bad366ed/document/document_559dfb750f15617.png',
syscall: 'open' } }
Regret I don't have enough reputation to make comment in this thread (node and Error: EMFILE, too many open files) so I have to create a new one to ask question.
My application has above error. I checked the log and the error occurred during a copying process (of template to user's login account and an admin account) when users first login.
I don't know idea why because it also occurred on some users account that the user did not login.
Can anyone help?

Raspberry PI mdns getaddrinfo 3008 error

I've this sample Node.js script:
var mdns = require('mdns');
var browser = mdns.createBrowser(mdns.tcp('http'));
browser.on('error', function (error) {
console.log("error");
console.log(error);
});
browser.on('serviceUp', function (service) {
console.log("serviceUp");
console.log(service);
});
browser.start();
On my Mac it's working fine, and two services is found. If I run the exact same script on my Raspberry PI 2 running Raspbean (connected to the same network), I get this output:
pi#raspberrypi ~ $ node mdns.js
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister>
error
{ [Error: getaddrinfo -3008] code: -3008, errno: -3008, syscall: 'getaddrinfo' }
error
{ [Error: getaddrinfo -3008] code: -3008, errno: -3008, syscall: 'getaddrinfo' }
A issue on the mdns GitHub, states that it's fair to ignore the warnings.
But what about the two errors? Is that some kind of configuration issue on my Raspberry PI?
It's a bad practice to modify node modules code locally.
You should better do the following when you create a mdns Browser:
var sequence = [
mdns.rst.DNSServiceResolve(),
'DNSServiceGetAddrInfo' in mdns.dns_sd ? mdns.rst.DNSServiceGetAddrInfo() : mdns.rst.getaddrinfo({families:[4]}),
mdns.rst.makeAddressesUnique()
];
var browser = mdns.createBrowser(mdns.tcp('http'), {resolverSequence: sequence});
Like said in this comment: https://github.com/agnat/node_mdns/issues/130#issuecomment-120731155
Thus, it will avoid bugs and allow everybody working on the project to get the same version and don't have to modify locally mdns code.
A solution was found on this GitHub issue:
https://github.com/agnat/node_mdns/issues/130
Modify Browser.defaultResolverSequence inside lib/browser.js in mdns.
Browser.defaultResolverSequence = [
rst.DNSServiceResolve(), 'DNSServiceGetAddrInfo' in dns_sd ? rst.DNSServiceGetAddrInfo() : rst.getaddrinfo({families:[4]})
, rst.makeAddressesUnique()
];

Why a mismatch between errno 34 and code ENOENT

So if I run this simple call in node.js v0.6.7 on OS X 10.6.8 with a bogus path, I get an error, as expected.
var fs = require("fs");
fs.stat("/tmp/foo", function(error, stat) {
return console.log(error);
});
It prints this output:
{ [Error: ENOENT, no such file or directory '/tmp/foo'] errno: 34, code: 'ENOENT', path: '/tmp/foo' }
My question is, according to /usr/include/sys/errno.h on my system, ENOENT should have code 2, so why is this error saying errno 34 (ERANGE in errno.h), but pairing it with the error message from ENOENT?
node.js translates system errnos to internal "errnos" (see deps/uv/include/uv.h and uv_translate_sys_error in deps/uv/src/unix/error.c or deps/uv/src/win/error.c for a mapping) as to achieve a common representation for error-conditions under Windows and Unix.
34 is the node.js-errno for ENOENT, so everything is alright.
It seems that node.js changed the errno with 0.12.0. ENOENT is -2now.
So it is probably better to check for code === 'ENOENT'
because you haven't created the folder /tmp/foo yet and it's looking for that folder
(when i added a few error handling lines to my code, the console spat out the same error code and it was because i had not yet created the directory i was telling it to save my images to)

Resources