Replies: 3 comments 3 replies
-
The Here is an example of a custom implementation https://github.com/home-assistant-libs/aioshelly/blob/main/aioshelly/rpc_device/wsrpc.py#L191 |
Beta Was this translation helpful? Give feedback.
-
The behaviour defined in the WebSocket spec is simply that upon receiving a PING frame you must respond with a PONG frame, nothing more. It is simply a convention that we use PING as a keepalive mechanism for the TCP connection (either for server side, and/or for the client to verify the server is still there).
As a server, we'd autoclose the connection after a timeout of not receiving a message. Receiving any message from the client tells us that the connection is still alive and therefore the TCP keepalive should remain active. It's completely illogical for a server to close the connection when receiving messages, just because none of them are PING messages. So, this seems like faulty server design, rather than anything worth changing in aiohttp. |
Beta Was this translation helpful? Give feedback.
-
The ping code has been rewritten in the last 6 months. Please give 3.11.x a try |
Beta Was this translation helpful? Give feedback.
-
According to code (and what I see as a side effect behaviour) client will reschedule
ping
call every time ws receive a message. In my case (I receive many messages and send nothing) this leads to server drop my connection as a silent one. I think ping/pong should not relly on activity and be simple as possible. Should I raise a bug on this?https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client_ws.py#L261
Beta Was this translation helpful? Give feedback.
All reactions