The websocket protocol defines special control frames for ping and pong, but they are not available through the JavaScript API. But if the server sends these frames, the browser will respond.
However, if the connection suddenly breaks and becomes a half-open connection , although the server detects it, the browser will not, therefore, I assume that sending your own letters at the application level is a good idea.
Answering your question, yes, this is a good idea, because if the connection becomes half open, your client does not receive updates, because he believes that he is connected. In websocket, the client must initiate the connection, so even if the browser implements disconnection, it cannot do anything to reconnect.
source share