-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dns.resolve
fails when the io/node process starts without an active network connection
#1644
Comments
I speculate that's because c-ares (the C library that powers dns.resolve()) reads /etc/resolv.conf once at start-up. If you start iojs when the network is disabled, /etc/resolv.conf is going to be empty. I'm not sure if it's fixable. iojs doesn't know when the network comes back up and even if it did, it may not be trivial to reinitialize c-ares. |
I thought that |
@silverwind Just tested on Ubuntu 14.04 64-bit with the same failure (original test was OS X 10.10.3). |
@johnthedebs What's the content of |
@silverwind It exists when all interfaces are disconnected, the contents are:
|
Right, thanks! |
|
This might be another motivation for #1013 |
|
Yes, someone would have to call |
Yup, without implemented |
Yeah, poll |
Correct, because parsing /etc/resolv.conf is not the only thing c-ares does. |
I just published a package It can be used to automatically monitor var resolvmon = require('resolvmon');
resolvmon.start(); // start monitoring
resolvmon.update(); // trigger manual update Some features of
Obviously this does not replace full /cc @johnthedebs |
Fix the bug that you start process without network at first, but it connected lately, `dns.resolve` will stay failed with ECONNREFUSED because c-ares servers fallback to 127.0.0.1 at the very beginning. If c-ares servers "127.0.0.1" is detected and its not set by user self, and last query is not OK, recreating `ares_channel` operation will be triggered to reload servers. Fixes: nodejs#1644
Fix the bug that you start process without network at first, but it connected lately, `dns.resolve` will stay failed with ECONNREFUSED because c-ares servers fallback to 127.0.0.1 at the very beginning. If c-ares servers "127.0.0.1" is detected and its not set by user self, and last query is not OK, recreating `ares_channel` operation will be triggered to reload servers. Fixes: nodejs#1644 PR-URL: nodejs#13076 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Fix the bug that you start process without network at first, but it connected lately, `dns.resolve` will stay failed with ECONNREFUSED because c-ares servers fallback to 127.0.0.1 at the very beginning. If c-ares servers "127.0.0.1" is detected and its not set by user self, and last query is not OK, recreating `ares_channel` operation will be triggered to reload servers. Fixes: nodejs#1644
Fix the bug that you start process without network at first, but it connected lately, `dns.resolve` will stay failed with ECONNREFUSED because c-ares servers fallback to 127.0.0.1 at the very beginning. If c-ares servers "127.0.0.1" is detected and its not set by user self, and last query is not OK, recreating `ares_channel` operation will be triggered to reload servers. Fixes: #1644 Backport-PR-URL: #14434 PR-URL: #13076 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Fix the bug that you start process without network at first, but it connected lately, `dns.resolve` will stay failed with ECONNREFUSED because c-ares servers fallback to 127.0.0.1 at the very beginning. If c-ares servers "127.0.0.1" is detected and its not set by user self, and last query is not OK, recreating `ares_channel` operation will be triggered to reload servers. Fixes: #1644 Backport-PR-URL: #14434 PR-URL: #13076 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Fix the bug that you start process without network at first, but it connected lately, `dns.resolve` will stay failed with ECONNREFUSED because c-ares servers fallback to 127.0.0.1 at the very beginning. If c-ares servers "127.0.0.1" is detected and its not set by user self, and last query is not OK, recreating `ares_channel` operation will be triggered to reload servers. Fixes: #1644 Backport-PR-URL: #14434 PR-URL: #13076 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
To reproduce:
Disable your Internet connection (this needs to be done first)
Start a io/node repl
Enter the following into the repl and note that it fails with
ECONNREFUSED
:var dns = require("dns");
dns.resolve("google.com", function(err) { if (err) { console.log(err); } else { console.log("online"); }})
Re-enable your Internet connection
Run
dns.resolve("google.com", function(err) { if (err) { console.log(err); } else { console.log("online"); }})
again, and note that it still failsIf the process starts before the Internet connection is disabled, it will work as expected once the connection is re-enabled.
For what it's worth, this bug doesn't affect
dns.lookup
(which according to the docs is implemented differently thandns.resolve
).The text was updated successfully, but these errors were encountered: