You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Different socket connection behavior between Node.js v18 and v20/22 with keepAlive #5152
Hi, I am encountering inconsistent socket connection behavior when migrating from Node.js v18 LTS to v22 LTS.
In v18, my TCP server using socket.setKeepAlive(true) maintains connections indefinitely as expected. However, in v22, the connections are being terminated unexpectedly after a specific idle period, even though keepAlive is explicitly enabled. I have verified that no firewall rules are changing.
Is this a known breaking change in the net module regarding keep-alive logic in recent versions? Or is there a new flag required to maintain legacy socket behavior?
Minimal Reproduction
const net = require('net');
const server = net.createServer((socket) => {
socket.setKeepAlive(true, 60000);
console.log('Client connected');
server.listen(8080, () => {
console.log('Server listening on 8080');
});
Output
No specific error message is thrown. The server simply logs "Client disconnected unexpectedly?" after the idle period, whereas in v18 the connection remains open indefinitely.
Before You Submit
I have looked for issues that already exist before submitting this
Activity