Einaros WS has the ability to send Ping and Pong frames, which are understood by most browsers and socket frameworks. I tested Socket Rocket on iOS and it had no problem understanding ping frames for Einaros. You need to come up with application-specific logic for how often to ping, as well as how many missed pongs you will endure. Einaros WS has ping () and pong () functions for sending ping pong or pong. You are listening to the pong event to find out when you received a response from customers. Here is how I do it in my code:
wss.on("connection", function(ws) { console.log("websocket connection open"); ws.pingssent = 0; var interval = setInterval(function() { if (ws.pingssent >= 2) {
In the case of Socket Rocket, no code is required on the client side. Therefore, compatible browsers and clients will respond Pongs automatically.
Praneeth wanigasekera
source share