Stop socket.io from reconnecting
socket.io
Solution
You might want to handle the reconnection yourself.
// Disables the automatic reconnection
var socket = io.connect('http://server.com', {
reconnection: false
});
// Reconnects on disconnection
socket.on('disconnect', function(){
socket.connect(callback);
});
Note: old versions used `reconnect` instead of `reconnection`.
Problem
Simple scenario: - Client connects to server with socket.io (`socket = io.connect(...)`) - Server crashes - Client tries to reconnect - User tells client to disconnect (`socket.disconnect()`) - Server starts - Client reconnects It seems that once socket.io starts attempting to reconnect, it cannot be stopped anymore. I want step 4 to prevent step 6 from happening, but it doesn't. What do I have to call instead?