in fact, it works as intended, when you disconnect the socket, you simply declare that you do not expect to receive more data from this socket right now, in order to actually destroy the socket, which you basically execute in the delete socket
action. Use this in case of shutdown, i.e.:
socket.on('disconnect', function(){ delete socket; })
You can also do this on the io.sockets.sockets object by an external function:
function deleteSocket(socketID){ delete io.sockets.sockets[socketID]; }
source share