-
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.js) Default happy eyeballs algorithm cause my request fail with a server in other side of the plannet #52216
Comments
EDIT: for continuity, some of this conversation is being continued on https://github.com/orgs/nodejs/discussions/48028#discussioncomment-7926376. I ran into this too on Node
Like OP, I was able to resolve this by setting I'm able to download the file just fine with both Curl and Python, so I know this isn't a total network failure or reachability problem. The above error only happens in Node. Anecdotally, it only started occurred after upgrading to Node |
After discussing this with @nwalters512 here, I am pretty sure this is due to #48145. |
@nwalters512 Can you please provide the result of From what I see in the aggregate error, this might not be a bug but an unfortunate DNS problems. @tniessen To prove this, I've created a quick test (note that if your system is able to connect before 10ms this test might fail):
In order to solve this configuration problem we have two ways, both unfortunately still to be implemented:
So, this is not directly related to #48145 but surely needs action. |
@ShogunPanda That was my hypothesis in the discussion linked above as well. I didn't say it's a bug — just known undesirable behavior of the existing implementation. |
@ShogunPanda here's that command and its output run from the machine in question: $ node -e "require('dns').lookup('nodejs.org', {all: true}, console.log)"
null [
{ address: '104.20.22.46', family: 4 },
{ address: '104.20.23.46', family: 4 },
{ address: '2606:4700:10::6814:162e', family: 6 },
{ address: '2606:4700:10::6814:172e', family: 6 }
] |
That confirms my opinion. |
Version
v20.11.1
Platform
Linux testserver 3.10.0-1160.114.2.el7.x86_64 #1 SMP Sun Mar 3 08:18:39 EST 2024 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
Net
What steps will reproduce the bug?
`
const { Socket } = require('net');
const sock = new Socket();
sock.connect({
host: 'latencyontheothersideoftheplanet.com',
port: 4222,
});
sock.on('connect', () => {
console.log('Connected to server');
// Send data to the server
sock.write('Hello, server!');
});
sock.on('data', (data) => {
console.log(
Received data from server: ${data}
);// Close the socket
sock.end();
});
sock.on('end', () => {
console.log('Disconnected from server');
});
`
I try to connect from a japan server to a european server.
Node 20.0.0, the default value of autoSelectFamily in socket.connect() changed from false to true.
in this case the latency is too high and "let autoSelectFamilyAttemptTimeoutDefault = 250;" define into Net.js is too low, so the query fail every time with a timeout for ipv4 (rais the timeout on algorithm) and with ENETUNREACH for ipv6 (this is normal as I dont have ipv6 network).
For fixing the issue (workaround) I set :
`
export NODE_OPTIONS=--no-network-family-autoselection
`
This parameter disable "happy eyeballs" algorithm add into ndoejs 20.
I know the timeout can be enlarge by "setDefaultAutoSelectFamilyAttemptTimeout" but this require an update of code.
I think its should be great to define this parameter as env variable for limiting breaking change not documented for this.
One more point, I think if there are no ipv6 network available no need to apply timeout.
How often does it reproduce? Is there a required condition?
you need to have a server with high latency connection greater than 250 ms
What is the expected behavior? Why is that the expected behavior?
I want my code works as on nodejs18 without timeout on connect with a server which has bad connection
What do you see instead?
I see a timeout on ivp4,
Additional information
No response
The text was updated successfully, but these errors were encountered: