I have found the problem.
In the server
I changed:
var io = require('socket.io').listen(8080);
to
var io = require('socket.io', { rememberTransport: false, transports: ['WebSocket', 'Flash Socket', 'AJAX long-polling'] }).listen(8080);
which forces the server to use either WebSockets, Flash Sockets, or long-polling. It wil try to use those in that order. The rememberTransport forces the server and client to forget which connection it used last, and try to connect with the 'transports' above.
On the client side I just pretty much did the same thing.
I added:
{ rememberTransport: false, transports: ['WebSocket', 'Flash Socket', 'AJAX long-polling']}
to the socket constructor. So it looked like:
var socket = io.connect('http://localhost:843', { rememberTransport: false, transports: ['WebSocket', 'Flash Socket', 'AJAX long-polling']});
Now it seems to work perfectly.
Thanks guys.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…