I am unable to figure out why disconnecting / connecting a socket.io connection multiple times is not working ?
Server side code:
io.on('connection', function(socket){
console.log('a user connected');
socket.on('disconnect', function(){
console.log('user disconnected');
});
});
Client side code:
var socket = io();
socket.on('connect', function() {
console.log("connected from the client side");
});
$('#connect_button').click(function(){
socket.connect();
});
$('#disconnect_button').click(function(){
socket.disconnect();
});
It disconnects alright. But doesn't reconnect. I'm using Socket.io 1.0. Please help.
This solution, based on Jujuleder's answer works. Apparently in socket.io 1.0, it is "forceNew" instead of "force new connection" - both work though.
Server:
Client (s.html):
Have you tried this config in client ?