uvicorn icon indicating copy to clipboard operation
uvicorn copied to clipboard

queue websocket disconnect for dropped connections

Open sephioh opened this issue 4 years ago • 2 comments

Using uvicorn with wsproto implementation, if clients do not close websocket connections properly, no exc will be sent to connection_lost (see code below).

As in the current version of uvicorn, this creates two issues:

  • apps will not receive websocket.disconnect events;
  • a zombie run_asgi (asyncio) task running for each non properly closed connection;

In order to reproduce the issue, follow instructions on this repo: https://github.com/sephioh/uvicorn-wsproto-issue

sephioh avatar Mar 09 '21 17:03 sephioh

seems like the exception check was added in https://github.com/encode/uvicorn/commit/3cab13283c849037e67b2c3afd64c57da3757f2c#diff-5f163724db1eaba811cc5e4ed55e529af488e351ee52ccfb7c1ad0329a8f0d92R65-R66 and I dont get the rationale given the context, I know it's been a while but do you remember why @almarklein or @tomchristie ?

euri10 avatar May 20 '21 15:05 euri10

Fixes https://github.com/encode/uvicorn/issues/997

euri10 avatar May 20 '21 15:05 euri10

Thank you for the PR @sephioh !

Also, sorry for the long waiting time.

Kludex avatar Oct 28 '22 13:10 Kludex