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

http/https modules should fallback to IPv4 when IPv6 connection fails #42275

Closed
cuihaoleo opened this issue Mar 10, 2022 · 1 comment
Closed

Comments

@cuihaoleo
Copy link

Version

v17.6.0

Platform

Linux cvhc-tomato 5.16.13-zen1-1-zen #1 ZEN SMP PREEMPT Tue, 08 Mar 2022 20:07:38 +0000 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

We use a IPv4/v6 dual-stack network. For some reason, we blocked some IPv6 ranges, including Google's, on our gateway. It returns "Address unreachable" for any access to these IPv6 ranges.

Usually HTTP clients fallback to IPv4 when v6 fails so the blocking doesn't prevent them from accessing Google. At least this is true for browsers, curl/wget and Python HTTP libraries.

But nodejs's HTTP(s) modules don't behave the same way. The following code:

http = require('http');
http.get("http://www.google.com").on("error", (e) => {console.log(e)});

will ends up with an error.

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior?

No response

What do you see instead?

> Error: connect EHOSTUNREACH 2607:f8b0:4007:80a::2004:80
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1158:16)
    at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
  errno: -113,
  code: 'EHOSTUNREACH',
  syscall: 'connect',
  address: '2607:f8b0:4007:80a::2004',
  port: 80
}

Additional information

Is it possible to change the behavior so that nodejs's HTTP(s) modules fallback to IPv4 when IPv6 connect fails, like other HTTP clients?

@Trott
Copy link
Member

Trott commented Mar 10, 2022

Duplicate of #41625.

@Trott Trott closed this as completed Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants