What to send in a Websocket ping and pong message | Sololearn: Learn to code for FREE!

0

What to send in a Websocket ping and pong message

Hi , i making a live stream for stocks / currency . In a Websocket cause the reaction speed is faster and its on every second . When the stream is running i received a ping = > 'b. ' Nothing else . So What must i send from the ping ? And when tot send a pong ? The docs online are not good .

5/20/2022 2:33:14 PM

Amal

1 Answer

New Answer

0

==What to send== Well it depends. If you want to test connection speed you don't generally send anything for best results. If you want to test how long X amount of bytes takes then you send an X bytes amount of payload. ==When to send== WebSocket is just a protocol so it depends on the language but when you ping your server, your server should have a response to that and in that response callback, you do the "sending" [Client requests a "ping"] [Server got the "ping" request so it must respond accordingly. Send a "hello" string. Job done close the request] [Client got the "hello" everything is fine. Job done]