Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should client or server send ping message?

I always thought it's the responsibility of the client to send a ping message to make sure server is available or handle disconnection in a proper way.

But lately I read an article where the initiator of ping messages is server side. So, server sends ping and client should respond with pong if it can.

What's the more general universal approach and why?

like image 439
Sergei Basharov Avatar asked Sep 12 '26 22:09

Sergei Basharov


1 Answers

According to the websocket RFC - examples, it shows Unmasked Ping request (Ping frame) and masked Ping response (Pong frame) where Ping is from server and Pong is from client.

But, Ping and Pong sections mention "endpoint" which can be either client or server.

So, client and server both should be able to send Ping frame and the other party should reply with Pong frame.

like image 107
Amila Senadheera Avatar answered Sep 14 '26 13:09

Amila Senadheera