You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
httpx hangs indefinitely when websocket is encountered #2517
Your curl output shows a classic upgrade flow. HTTP/1.1 101 Switching Protocols means the server accepted a WebSocket upgrade and will hold the TCP connection open instead of returning a normal HTTP body.
That tends to confuse tools built for request–response probing. httpx reads the Upgrade: websocket header, sees the 101, then keeps waiting on the stream because the connection never closes. No body arrives. The timeout path never fires.
I hit the same behaviour with a WS endpoint a while back. The simple fix was treating 101 as a finished probe. Read headers, record the status, then close immediately. In Go that usually means returning as soon as resp.StatusCode == 101 instead of attempting io.ReadAll on the body. That header-only branch should stop the hang.
Activity
sophymarine commentedon Jun 18, 2026
Your curl output shows a classic upgrade flow.
HTTP/1.1 101 Switching Protocolsmeans the server accepted a WebSocket upgrade and will hold the TCP connection open instead of returning a normal HTTP body.That tends to confuse tools built for request–response probing. httpx reads the
Upgrade: websocketheader, sees the101, then keeps waiting on the stream because the connection never closes. No body arrives. The timeout path never fires.I hit the same behaviour with a WS endpoint a while back. The simple fix was treating
101as a finished probe. Read headers, record the status, then close immediately. In Go that usually means returning as soon asresp.StatusCode == 101instead of attemptingio.ReadAllon the body. That header-only branch should stop the hang.