Disabling Socket.io heartbeats (Node.js)

The socket.io documentation mentions that heartbeat can be turned off as follows:

io.disable('heartbeats');

Unfortunately, while this seems to stop sending audio signals, clients still disconnect when they do not send audio signals.

The following does not work either:

io.set('heartbeats', false);

I tried setting some intervals to 0 without success:

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

Any suggestions on what might turn off heartbeats correctly?

+4
source share
3 answers

Code

 io.disable('heartbeats'); 

Tested successfully on socket.io v0.8.7

Without tripping

 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 

Off

debug - authorized client

 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"}]} 
+4
source

Something is wrong with heart contractions. I have the latest socket.io and node 0.6.X

  info - socket.io started debug - client authorized info - handshake authorized 734447051478827620 debug - setting request GET /socket.io/1/websocket/734447051478827620 debug - client authorized for debug - websocket writing 1:: debug - websocket writing 5:::{"name":"hello"} info - transport end (socket end) debug - set close timeout for client 734447051478827620 debug - cleared close timeout for client 734447051478827620 debug - discarding transport // server code var io = require('socket.io').listen(8080); io.disable('heartbeats'); io.sockets.on('connection', function (socket) { socket.emit('hello'); }); 

The client disconnects immediately after connecting.

+3
source

Set socket.io log level, with log level 2 we will not see all the heartbeats of each socket, but only handshakes and disconnects

io.set ("log level", 2);

0
source

All Articles