Add interval and count to keep-alive #729

wants to merge 1 commit into


None yet
3 participants

The default probe interval and failure counts set by the OS are way too extreme and if you have a real-time socket server, you're going to want to customize these so you can have a much lower keep-alive interval and count so you're notified of disconnected sockets sooner.

Unfortunately, Windows doesn't let you set count, but using SIO_KEEPALIVE_VALS we can set interval (see: The defaults for the OS are 2 hour timeouts and 1 second intervals. I was hesitant about setting the default 1 second because that's pretty insane but decided just to leave it.

According to the node docs "Setting 0 for initialDelay will leave the value unchanged from the default (or previous) setting.". So I've added the delay back to the if checks in tcp.c to keep that true.

fastest963 referenced this pull request in nodejs/node-v0.x-archive Mar 1, 2013


Added interval and count options to setKeepAlive. #4882

@fastest963 fastest963 Add keep-alive interval and count options.
The default probe interval and failure counts set by the OS are
too extreme. Lowering them will allow you to know when clients
disconnect sooner, which is helpful if you're running a chat server.

hertzg commented Jan 29, 2015

Any updates on this?


saghul commented Jan 29, 2015

@hertzg Looks like this fell through the cracks long time ago. The problem with this patch now is that it changes the API and thus it cannot land in v1.x. That aside, the values are not stored and thus lost if the socket was not yet created.

There is a proposal to create sockets early: libuv/leps#5 which would simplify the problem, because the values can always be set.

Either way, libuv moved over to, so please open a new issue there. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment