Closed WSH032 closed 3 months ago
I think we've found a bug in Uvicorn ๐ I've digged this and it turns out that Uvicorn omits to set the reason when they receive a close event, both in the wsproto
and websockets
implementation:
I tried with a simple fix and the issue you described was solved. I'll propose a PR there to fix this ๐
Actually, the problem is a bit more complex. Follow here: https://github.com/encode/uvicorn/discussions/2299
Oh, sorry for reporting the wrong issue.
I'm not very familiar with the ASGI specification, and I couldn't find any relevant issues in the repos of uvicorn
and hypercorn
. This led me to mistakenly think it was an issue with httpx-ws
, but actually httpx-ws
works fine.
Thank you for your quick response๐! Perhaps we should close this issue as not planned?
No worries! TBH, I was surprised to discover that it was actually not my fault ๐
I would like to keep this open for the time being to keep track of this and see if we can push lines downstream!
Great, thank you! Solving this problem will also benefit my downstream libraries.
This is now solved with uvicorn>=0.30.2
.
Very glad that we were able to track down this issue, which lead to fix an omission in the ASGI spec itself ๐
Describe the bug
When closing a WebSocket connection,
httpx-ws
can correctly send the close code, but it is unable to send the close reason.To Reproduce
Run following code
You can see:
This is a colab demo, click to run
Expected behavior
WebSocketDisconnect
should be(1002, 'Bye')
Configuration
fastapi==0.110.1 httpx-ws==0.6.0 anyio==4.3.0 uvicorn==0.29.0 hypercorn==0.16.0