socket.io-client holds the running status after a while on disconnection
Problem
server.js
var io = require('socket.io').listen(3000);
io.sockets.on('connection', function (socket)
{
console.log("server is connected");
socket.on('disconnect', function ()
{
console.log("disconnected");
});
});
client.js
var socket = require('socket.io-client')
.connect('http://localhost:3000/')
.on('connect', function ()
{
console.log("client connected");
socket.disconnect();
})
.on('disconnect', function ()
{
console.log('client disconnected');
//not going to finish the client.js app imediately.
});
Why?
socket.io-client holds the Running Status about 1 minutes after the disconnect event.
Is there any fundamental fix or smart workaround?
node.js v0.8.8
socket.io v0.9.10
socket.io-client v0.9.10
Problem courtesy of: Ken OKABE
Solution
Seems like a bug to me. If you don't want to wait you can do process.exit()
in disconnect callback.
Solution courtesy of: vinayr
Discussion
View additional discussion.