Disabling Socket.io heartbeats (Node.js)

Tom picture Tom · Sep 8, 2011 · Viewed 10.3k times · Source

The socket.io documentation mentions that heartbeats can be disabled like so:

io.disable('heartbeats');

Unfortunately, while this seems to stop the hearbeats from being sent, the clients still disconnect when they are not sending hearbeats.

The following does not function either:

io.set('heartbeats', false);

I have tried setting some intervals to 0, without success:

io.set('heartbeat timeout', 0);
io.set('heartbeat interval', 0);

Any suggestions on what might properly disable heartbeats?

Answer

First Zero picture First Zero · Dec 22, 2011

The code is

io.disable('heartbeats');

Tested successfully on socket.io v0.8.7

Without disabling

debug - emitting heartbeat for client 299833185260419425
debug - websocket writing 2::
debug - set heartbeat timeout for client 299833185260419425
debug - got heartbeat packet
debug - cleared heartbeat timeout for client 299833185260419425
debug - set heartbeat interval for client 299833185260419425

With disabling

debug - client authorized

info  - handshake authorized 1205975980561506547
debug - setting request GET /socket.io/1/websocket/1205975980561506547
debug - client authorized for 
debug - websocket writing 1::
debug - websocket writing 5:::{"name":"news","args":[{"hello":"foo"}]}