I am struggling to find any documentation about a timeout value for socket.io. I am using //cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js on the client and Flask-SocketIO on the server side.
Here is how I am creating the socket:
namespace = '/coregrapher'
var socket = io.connect('http://' + document.domain + ':' + location.port + namespace);
socket.on('connect', function() {
socket.emit('my event', {data: 'I\'m connected!'});
});
socket.on('my response', function(msg) {
$('#result').append(msg.data);
});
The issue is, if the server does not send anything to the client or visaversa for even one minute, the client disconnects and if the server tries to do another emit to the client, it fails because the client has already disconnected. How can I make the client stay connected?
Thanks!
The big picture issue is that if your server is non-responsive to keep-alive packets for some extended period of time, the client will drop the connection and try to reconnect. If it cannot reconnect, eventually, it will stop trying.
That said, if you want to modify the configuration of the retry logic, then you can send an options object as the 2nd argument to your
.connect()
call. Per the documentation here, there is control over the following options:So, if you want it to keep trying to reconnect automatically for a much longer period of time, you can increase the times for the last three options.