-
Notifications
You must be signed in to change notification settings - Fork 30k
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
net: improve error message when no address #239
Conversation
when use 'listen(80)' will get the 'listen EACCES null:80'. this fix will make the error message better. like 'listen EACCES 0.0.0.0:80'.
e1a03ad
to
5d7328a
Compare
ping @reviewers |
@@ -1135,6 +1135,7 @@ Server.prototype._listen2 = function(address, port, addressType, backlog, fd) { | |||
debug('_listen2: create a handle'); | |||
var rval = createServerHandle(address, port, addressType, fd); | |||
if (util.isNumber(rval)) { | |||
address = address || '0.0.0.0'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work on machines that only have IPv6 configured?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cjihrig , the listen will fallback to IPv4, when IPv6 failed.
if (address || port || isTCP) {
debug('bind to ' + (address || 'anycast'));
if (!address) {
// Try binding to ipv6 first
err = handle.bind6('::', port);
if (err) {
handle.close();
// Fallback to ipv4
return createServerHandle('0.0.0.0', port);
}
} else if (addressType === 6) {
err = handle.bind6(address, port);
} else {
err = handle.bind(address, port);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice before that this is just for formatting an exception. I don't know how I feel about setting the value artificially just for that, but I'm OK with the rest of the PR.
fixed by #539 |
when use 'listen(80)' will get the 'listen EACCES null:80'. this fix will
make the error message better. like 'listen EACCES 0.0.0.0:80'.