I've been searching over the web about the problem I'm having with socketio client on 3g/4g networks. It seems to connect, but doesn't keep connected for long, it keeps connected for about 60 seconds then disconnect, connecting again when the reconnecting attempt events trigger, but reepats the above behavior.
Does anyone know why this happens or how to solve it?
Thanks in advance!
Heres a sample of the code i'm using to start de socket:
var socketOpts = {
reconnect: true,
reconnectionDelayMax : 2500,
timeout : 10000,
transport: ['polling','websocket']
};
socket = io.connect( $scope.socket_addr, socketOpts );
showMessage( true, "Aguardando conexão com o servidor!", true );
/* Abaixo estão os eventos que o Socket pode disparar durante o funcionamento do app */
/* Quando o Socket conectar no servidor */
socket.on("connect", function()
{
$scope.socket_connected = true;
/* Agora que o socket já conectou, posso alterar o tempo de ping */
socket.io.engine.pingInterval = 3000;
socket.io.engine.pingTimeout = 5000;
showMessage( false, "", false );
console.log( "WS conectado" );
});
Setting these options to delay the reconnection worked :-)
Or in Ionic