Issue in socket reconnection

Viewed 124

I have an app that has socket features. I could notice that the app is trying to reconnect frequently when the app is in an idle state. Is there any way that I could maintain a stable connection with the server without reconnections?

Connection drops even though I am receiving pings every 5 seconds. I need the connection to be alive until I close it.

I have configured my server with pingIntervals as below:

var io = require('socket.io')(server, {
    pingInterval: 5000, 
    pingTimeout: 15000
});

Client-Side Configuration:

io(TENANT_URL, {
    transports: ['websocket', 'polling'],
    autoConnect: false,
    'reconnection': true,
    'reconnectionDelay': 10000,
    'reconnectionDelayMax': 5000,
    'reconnectionAttempts': 10
});

Is there anything that I can do with the configuration to make the connection stable?

Reconnection timings: enter image description here

1 Answers

You need to sync the heartBeat timeouts and Intervals in the client side too.

Client-Side

io.pingTimeout = 15000
Related