I have a simple chat app with node.js and socket.io: tutorial full code
It works perfectly if the clients enters the website from a PC. If the client uses a IPad (ios 5.1/ latest Chrome / safari) it only works sometimes. Most of the time the webpage is loaded, then the iPad connects, but it takes so long that the server closes the connection. Then the iPad gets a new connection, but cannot really initialize a session. It periodically is disconnected and tries to reconnect again.
Here the protocoll of socket.io:
client code:
socket = io.connect(http://42.58.240.427:4000);
socket.on('connect', function(){
send('init');
});
server code:
io.sockets.on('connection', function (socket) {
socket.on('init', function(){
console.log("Good morning new User");
});
socket.on('disconnect', function(){
requesthandler['disconnect'](socket, io);
});
I am guessing it is due to browser websocket support. iOS Safari (5.0-5.1) browser implements an older websocket protocol (Hixie-76). So it only supports websocket partially. See the websocket support chart.
When you say it works sometimes, most likely it is falling back to long-polling. It can be connected this way but it can have timeout problems. See the differences between websocket and long-polling in this question. The reconnect happens by default. But timeout will happen.
So it is best to upgrade the browser to latest version which fully supports websockets.