In socket.io, the disconnect event does not fire when xpx polling is active. If I switch the transport to websites, it works fine, but in the xhr poll it doesn't work.
var express = require('express'),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server);
server.listen(1337, null);
io.set('transports', ['xhr-polling']);
app.get('/', function (req, res) {
res.sendfile("index.html");
app.use(express.static(__dirname));
});
io.sockets.on('connection', function (socket)
socket.on('disconnect', function() {
console.log('LOL');
});
});
In the following code, the disconnect does not work, but if I delete the line -
io.set('transports', ['xhr-polling']);
It works fine, so why doesn't it work with xhr polling? but only with websockets?
How can i fix this? Am I missing something?
Thanks in Advance;)
source
share