Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

JacksonTian
Copy link
Contributor

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'.

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'.
@JacksonTian
Copy link
Contributor Author

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';
Copy link
Contributor

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?

Copy link
Contributor Author

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);
    }
  }

Copy link
Contributor

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.

@vkurchatkin
Copy link
Contributor

fixed by #539

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net Issues and PRs related to the net subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants