flask-uwsgi-websocket icon indicating copy to clipboard operation
flask-uwsgi-websocket copied to clipboard

Asyncio "no PONG received in 3 seconds" after 30 seconds

Open oplatek opened this issue 8 years ago • 3 comments

Hi, I am wondering if the asyncio implementation sends the PINGs in the background because I receive no PONG received in 3 seconds every single time after 30 seconds.

My understanding is that the ping is sent every websocket.timeout in seconds and the websocket waits 3 seconds to receive PONG message, am I right?

oplatek avatar Feb 05 '17 23:02 oplatek

Sorry for a late reply. In brief, not quite. websocket.timeout is not supposed to be the exact PING/PONG period yet quite related. Indeed PING/PONG messages are managed by uwsgi's websocket implementation, but uwsgi exposes no related api. Theoretically that timeout should not be necessary. If we use either bare uwsgi or the blocking uwsgi.websocket_recv, PING/PONG messages would be handled by uwsgi automatically. But once behind a reverse proxy or a load balancer, which would be a trivial setup, without calling uwsgi.websocket_recv_nb or uwsgi.websocket_recv uwsgi might not handle PING/PONG messages properly, resulting a timeout disconnect. So, websocket.timeout is just used to periodically trigger uwsgi to handle PING/PONG messages, and uwsgi will decide whether it should be sent which we cannot control.

stepheny avatar Mar 01 '17 13:03 stepheny

Hi

I use this repo to stream client microphone samples to server. Unfortunately, every time I get aforementioned error, which consequences client websocket to close and so the program stop working...

If there is no way to control such crucial parameter of uwsgi, I think you choosed inappropriate library as base! Please give my start back!

This seems to be a bug in uwsgi, see this pull request: https://github.com/unbit/uwsgi/pull/1261.

ajs124 avatar Nov 17 '17 16:11 ajs124