endpoints icon indicating copy to clipboard operation
endpoints copied to clipboard

uWSGI websocket handling with timeouts

Open Jaymon opened this issue 4 years ago • 0 comments

Right now the uWSGI Connection doesn't surface timeouts, it would actually be great if the Application object had a timeout handler that has the connection send a ping instead of the connection itself swallowing this timeout and sending the ping.

This way, downstream child classes can customize what the connection should do on timeout.

It should also have a mechanism or send a ping when it receives something but the thing it receives is empty.

Basically, change this to something like:

payload = uwsgi.websocket_recv_nb()
if payload and payload != 'undefined':
     yield payload

else
     # call a handler so downstream classes can handle this issue

And change this so it yields a timeout:

if not ready[0]:
     # send websocket ping on timeout
     uwsgi.websocket_recv_nb()
         continue

to something like:

if not ready[0]:
     # call downstream or yield None so downstream code can handle timeout

Jaymon avatar Apr 21 '20 22:04 Jaymon