Using
Web application NodeJS + Socket.io (network sockets only, bit enabled).
Problem
My application works fine (it connects to Socket.io, it emits / receives messages correctly), but I detect random outages, and not because of heart rate timeouts. Even if the server receives a packet packet from a client, it is still possible that it will disconnect this client in a few seconds. And I do not understand the reason. This happens almost by accident, approximately every 3-15 minutes . Changing the configuration of socket.io does not seem to affect the frequency.
Here is the log, and it clearly shows that the reason for the shutdown is not the pulse timeout , but the end of the transfer (end of the socket) :
Log:
debug: emitting heartbeat for client cTVCsv2GS2R_lh3Ecao- debug: websocket writing 2:: debug: set heartbeat timeout for client cTVCsv2GS2R_lh3Ecao- debug: got heartbeat packet debug: cleared heartbeat timeout for client cTVCsv2GS2R_lh3Ecao- debug: set heartbeat interval for client cTVCsv2GS2R_lh3Ecao- info: transport end (socket end) // ^ Why? debug: set close timeout for client cTVCsv2GS2R_lh3Ecao- debug: cleared close timeout for client cTVCsv2GS2R_lh3Ecao- debug: cleared heartbeat interval for client cTVCsv2GS2R_lh3Ecao- SOCK 25.12 22:23:20.675 disconnection from IO detected (USER1) // ^ This means disconnected event fired debug: discarding transport debug: client authorized info: handshake authorized GPBLHsqhhrdsTeqTcao_ debug: setting request GET /socket.io/1/websocket/GPBLHsqhhrdsTeqTcao_?conftoken=20519986772 debug: set heartbeat interval for client GPBLHsqhhrdsTeqTcao_ debug: client authorized for debug: websocket writing 1:: debug: client authorized for /io/activity debug: websocket writing 1::/io/activity SOCK 25.12 22:23:23.005 reconnected to IO (USER1)
Configuration
Client:
socket = io.connect('/io/activity',{'max reconnection attempts':Infinity})
Server:
io = require('socket.io').listen(server, { log: true , "close timeout": 120 , "heartbeat timeout": 120 , "heartbeat interval": 30 , "transports": ["websocket"] }) io.enable('browser client minification') io.enable('browser client etag') io.enable('browser client gzip')
igorpavlov
source share