I am trying a simple chat application here with socket.io and node.js. Every time I restart the node.js server, socket.io automatically reconnects and somehow creates one mo
Try to write the index.html in this way instead:
iosocket.on('connect', function () {
$('#incomingChatMessages').append($('- Connected
'));
});
iosocket.on('message', function(message) {
$('#incomingChatMessages').append($('').text(message));
});
iosocket.on('disconnect', function() {
$('#incomingChatMessages').append('- Disconnected
');
});
It may be caused by the other 2 eventlisteners was registered to the connect event. When the client disconnected, the other 2 listeners will still here and doesn't get unregistered.