So this is part of a larger app, that I was trying to get running with cluster, and socket.io-redis so it would work across multiple nodes and machines if I need to scale in the future.
I seem to be getting severe issues with some clients not being able to maintain connections. Some clients do this persistently (mostly iOS devices, which I imagine must be using polling transport), but others sometimes work, and sometimes dont (which again I'm attributing to using polling).
I stripped back everything, and turns out cluster wasn't the issue.
Anyways my server.js
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var port = process.env.PORT || 3800;
/* -------------------------------- */
io.on('connection', function(socket){
var datetime = new Date().toLocaleString();
console.log(datetime+' - '+'a user connected - '+socket.id);
});
/* -------------------------------- */
http.listen(port, function() {
var datetime = new Date().toLocaleString();
console.log(datetime+' - '+'listening on *:' + port);
});
and output in the console
Wed Mar 11 2015 16:22:53 GMT+0000 (GMT) - listening on *:3800
Wed Mar 11 2015 16:22:54 GMT+0000 (GMT) - a user connected - YrLUOrgfpnQVwoWMAAAA
Wed Mar 11 2015 16:22:58 GMT+0000 (GMT) - a user connected - nH6x-97uf3iR2LgNAAAB
Wed Mar 11 2015 16:23:01 GMT+0000 (GMT) - a user connected - VsrFO31elPyKfQJcAAAC
Wed Mar 11 2015 16:23:08 GMT+0000 (GMT) - a user connected - 7xuKZ6aykYIDcxN-AAAD
Wed Mar 11 2015 16:23:15 GMT+0000 (GMT) - a user connected - ZsmZtFHmLrH1DxXWAAAE
Wed Mar 11 2015 16:23:22 GMT+0000 (GMT) - a user connected - HFUApMwwFZallJnQAAAF
This just goes on indefinitely. I am testing it with an iPad, with the client loading from within an appgyver supersonic app (cordova and javascript).
I get the same issue when using a fork of the socket.io chat example, modified for cluster use - https://github.com/evilstudios/chat-example-cluster
My Question: Why are some clients unable to retain a connection? How do I fix these issues with the polling transport not maintaining a single session?