I have a node.js server, and I use socket.io to exchange in real time between the server and clients. I noticed that if a mobile client (using the Ionic Framework) suddenly disconnects without notifying the server, the sockets live for hours (or forever). I read and looked at their documentation, and they have options like pingInterval, pingtimeout, heartbeat interval, heartbeat timeout, close timeout .
How to configure these values ββon my server?
Which of these values ββare out of date?
Here is my code.
var express = require('express'); var app = express(); var server = require('http').createServer(app); var io = require('socket.io').listen(server); io.set('heartbeat interval', 5000); io.set('heartbeat timeout', 8000); io.set('timeout', 5000); io.on('connection', function(socket){...}
None of this works. Any help or guidance is much appreciated.
PS: I connect the sockets of my collection when the client disconnects and it works fine when the clients tell the server that they want to disconnect gracefully.
Samarth agarwal
source share