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: setKeepAlive options ignored before connect #31663

Open
lgpasquale opened this issue Feb 6, 2020 · 2 comments
Open

net: setKeepAlive options ignored before connect #31663

lgpasquale opened this issue Feb 6, 2020 · 2 comments
Labels
net Issues and PRs related to the net subsystem.

Comments

@lgpasquale
Copy link

  • Version: v13.7.0
  • Platform: linux 5.5.2
  • Subsystem: net

If setKeepAlive() is called on a tcp socket before the connect event, then the initialDelay parameter is ignored.
This bug was alread reported here for version 0.12, but it still seems to be there in 13.7.

If, for instance, I call setKeepAlive(true, 10000) before the connect event, the default initialDelay of 7200s is used.
netstat -ntp --timers gives:

tcp        0      0 10.10.15.220:56866      10.10.15.148:6666       ESTABLISHED 132820/node          keepalive (7132.09/0/0)
@targos targos added the net Issues and PRs related to the net subsystem. label Dec 26, 2020
@pmarrapese
Copy link

  • Version: v14.15.4
  • Platform: Windows [Version 10.0.17763.1637]

Confirmed this still behaves this way. In this example, Wireshark shows the first keepalive packet going out 60 seconds after the connection is established.

const net = require('net');

let socket = net.createConnection({
 host: 'localhost',
 port: 31337
});
socket.setKeepAlive(true, 1000);
socket.on('connect', () => {
 console.log('socket is connected');
});

Moving the setKeepAlive call into the connect handler causes them to go out every 1s, as intended. If there is no intention to modify this behavior, this should at least be noted in the documentation.

@oyyd
Copy link
Contributor

oyyd commented Jun 30, 2022

Looks like this has been solved in #41310.

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

No branches or pull requests

4 participants