Answer the question
In order to leave comments, you need to log in
Is my socket.io getting disconnected?
Hello. Faced with a situation when the client falls off in sockets at inactivity. Implemented pingpong, as a result, the following problem was found out. The socket is lost when the page is not active in the browser, is there any way to fix it?
This question is a repetition, therefore, for those who suffer, I will immediately give an example of a standard ping pong that I use.
Server
function sendHeartbeat(){
setTimeout(sendHeartbeat, 8000);
io.sockets.emit('ping', { beat : 1 });
}
io.sockets.on('connection', function (socket) {
socket.on('pong', function(data){
console.log("Pong received from client");
});
}
setTimeout(sendHeartbeat, 8000);
socket.on('ping', function(data){
socket.emit('pong', {beat: 1});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question