4 ms·
Websockets certainly has simple heartbeats. It has Ping and Pong frames defined in the spec: https://html.spec.whatwg.org/multipage/web-sockets.html#ping-and-po
by kccqzy 7y ago
Websockets certainly has simple heartbeats. It has Ping and Pong frames defined in the spec: https://html.spec.whatwg.org/multipage/web-sockets.html#ping-and-pong-frames https://html.spec.whatwg.org/multipage/web-sockets.html#ping...
The libraries I use tend not to enable it by default, but they are generally implemented.
- ex3ndr 7y agoYes, they are just not implemented anywhere. Even MDN is not mentioning it: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
- kccqzy 7y agoMDN doesn't mention it because MDN is focused on web developers writing code for browsers. Pings are sent from the server to the browser. Browsers are supposed to automatically send Pongs back to the server. So a client implementation has no reason to know about Pings or Pongs—it's handled by the server or the browser.
- ex3ndr 7y agoNo one cares about server side pings. On server it is not an issue at all - feel free to hold dead connections for a while. Networking issues are always on customer side, you have to detect it from the app otherwise it will literally freeze.