Codespaces port forwarding adds duplicated Connection: keep-alive
header breaking Websockets connection upgrade
#57596
Replies: 4 comments 5 replies
-
I managed to patch Uvicorn to fix this problem: But I am not sure if it is Uvicorn that should be patched or the GitHub codespaces reverse proxy that sends a malformed HTTP request. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback and the detailed report! I'll share this back with the port forwarding team. |
Beta Was this translation helpful? Give feedback.
-
Any plans to fix the headers with the default url? |
Beta Was this translation helpful? Give feedback.
-
@joshspicer I am wondering if there is any ETA on the new port forwarding? :) There are some other issues with the current preview. version that seems to be fixed in the new version. Thank you! |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Bug
Body
I am running Uvicorn in GitHub Codespaces. I am forwarding a port with visibility public and port protocol HTTP.
My first Websocket connection works, but after a few seconds the Websocket endpoint starts returning HTTP 404.
I captured traffic at the Uvicorn server with tcpdump and I figured out that when I receive a HTTP 404 the HTTP request has a duplicated
Connection
header.This is a problem and looking at the Uvicorn implementation it will make the Websockets connection fail to upgrade randomly depending on which one of the duplicated
Connection
header is read first.https://github.com/encode/uvicorn/blob/1cb58c707ae7203f3b24e714947e7ab025b20895/uvicorn/protocols/http/h11_impl.py#L173-L183
According to RFC7230 there should not be duplicated
Connection
headers.I suspect GitHub codespaces reverse proxy is adding this header to the request, but it should actually not doing it.
Please could anyone confirm the proxy adding the duplicated
Connection: Keep-Alive
header is the root cause of the problem ? Or I should propose a PR to unicorn to deal with these duplicated headers ?Thank you
Related discussions:
https://github.com/orgs/community/discussions/41915
https://github.com/orgs/community/discussions/3908
Beta Was this translation helpful? Give feedback.
All reactions