I have a websocket application in which the server (written in Java by using Netty) periodically sends ping frames to clients to detect if their connections are still alive (indeed it may happen that the client's network connection goes down and the server is not able to detect it). But what if a particular browser does not support the ping-pong function? How can I detect it in javascript? E.g., for websocket I use if(!window.WebSocket) {...}, but what about ping-pong?

有帮助吗?

解决方案

A WebSocket client that does not support ping/pong is not compliant with RFC6455 - the feature is mandatory.

All major browsers support ping/pong.

There is no way of detecting the feature from JavaScript.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top