uvicorn icon indicating copy to clipboard operation
uvicorn copied to clipboard

Add `WebSocketsSansIOProtocol`

Open Kludex opened this issue 1 year ago • 4 comments

Kludex avatar Dec 14 '24 16:12 Kludex

@aaugustin Do you have availability to review this in the next days?

Kludex avatar Dec 14 '24 16:12 Kludex

Seems like I need to drop Python 3.8 to make my life easier. 👀

Kludex avatar Dec 14 '24 17:12 Kludex

I'm making a note to look into it tomorrow. If I don't find time tomorrow, then I'll do over the Christmas break.

aaugustin avatar Dec 14 '24 17:12 aaugustin

Hi! I'm just leaving a comment to say that I'm running into the issue this fixes, and I'm greatly anticipating this being merged. Let me know if there's anything I can do to help.

ilyakamens avatar Jan 14 '25 17:01 ilyakamens

Is there any hope this PR could be finished/merged? 😅

FeodorFitsner avatar Jun 18 '25 21:06 FeodorFitsner

Is there any hope this PR could be finished/merged? 😅

It's going to happen at some point. No ETA. Not much needed to finish this PR tho.


Funny. I am at PyCon SG and I heard a talk about flet yesterday. Nice stuff! 😁

I don't understand why your project has both hypercorn and Uvicorn as dependencies tho.

Kludex avatar Jun 18 '25 21:06 Kludex

Ah, great! :)

I don't understand why your project has both hypercorn and Uvicorn as dependencies tho.

Good catch, it was probably added during the testing of some options. Flet uses Uvicorn as a built-in web server and it's awesome.

FeodorFitsner avatar Jun 18 '25 22:06 FeodorFitsner

@aaugustin Pipeline is passing. Do you have time to give a last look? (also, sorry for the delay)

Things that I skip in this PR:

  1. We are not testing CONT frames.
  2. We are not testing when there's a parser issue.

I'd like to have those 2 points tested, but I don't want to spend more time in this to have this merged.


I also think that WebSockets merits more documentation in Uvicorn.


Besides that, I checked all the comments above, and none of them seem to block this PR to get merged (correct me if wrong @aaugustin).

Kludex avatar Jun 21 '25 05:06 Kludex

I will have a look this week-end.

aaugustin avatar Jun 21 '25 07:06 aaugustin

We are not testing CONT frames.

They're uncommon in real life and your implementation is simple enough that it's probably right :-)

If you want to do a quick manual test, you can run this:

import asyncio
from websockets.asyncio.client import connect

async def fragmented_hello():
    async with connect("<address of echo server built with uvicorn>") as websocket:
        await websocket.send(["Hell", "o!"])
        await websocket.recv()

if __name__ == "__main__":
    asyncio.run(hello())

We are not testing when there's a parser issue.

The parser is hardened and quite hard to crash. oss-fuzz has been trying to crash if for several years now (https://github.com/python-websockets/websockets/blob/main/fuzzing/fuzz_websocket_parser.py) and hasn't crashed it yet.

aaugustin avatar Jun 21 '25 12:06 aaugustin