I keep reading about ping/pong messages in websockets to keep the connection alive, but I\'m not sure what they are. Is it a distinct frame type? (I don\'t see any methods
In case the WebSocket server initiative disconnects the
wslink after a few minutes there no messages sent between the server and client.
client sends a custom ping message, to keep alive by using the keepAlive function
server ignore the ping message and response a custom pong message
var timerID = 0;
function keepAlive() {
var timeout = 20000;
if (webSocket.readyState == webSocket.OPEN) {
webSocket.send('');
}
timerId = setTimeout(keepAlive, timeout);
}
function cancelKeepAlive() {
if (timerId) {
clearTimeout(timerId);
}
}