-
Notifications
You must be signed in to change notification settings - Fork 27
Description
AFAICT, httpx-ws only supports Upgrading HTTP1.1 to WebSocket connections.
There is an RFC8441 for establishing WebSockets over an HTTP2 connection as well.
This would be amazing to have since the websockets would be multiplexed over a single TCP connection, whereas over HTTP1.1 websockets take up a whole TCP connection, limiting performance.
I briefly tried adding this to httpx-ws by changing the method to CONNECT, changing the expected status code to 200, and adding {":protocol": "websocket"} to the beginning of the headers here (afaict h2 correctly adds it as a pseudo header if you give it as one of the first headers within httpx). I think the network_stream extension of httpx represents an HTTP2 stream already if HTTP2 is used.
Unfortunately, it does not quite work yet.
Caddy (>=2.9.0 should support h2ws) resets my stream and Hypercorn apparently does not receive messages after accepting the h2ws connection.
I cannot spend anymore time on this for now.
Thank you for your work on this library.