-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net/http: Client.Timeout doesn't work when receiving a response from an incomplete WebSocket handshake #71325
Comments
Change https://go.dev/cl/646035 mentions this issue: |
I think this is the responsibility of the WebSocket implementation to deal with. Hijacking an HTTP/1 connection transfers ownership of the |
On the server side, there's Hijack / ResponseController to explicitly take control of the underlying connection. But this report is about the client side, which does not specify any parameters in the request that it expects to be hijacked, and the client / transport implementation automatically hijacks the connection for you on receiving the headers the server sent. |
Go version
go version go1.23.4 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I encountered a situation where http.Client.Timeout doesn't work as expected when reading response body from an incomplete/fake WebSocket handshake response. Here's a minimal reproduction:
https://go.dev/play/p/i0mxl_6BaZR
What did you see happen?
The client appears to be permanently blocked when reading the response body despite having a client timeout set. The timeout doesn't trigger as expected, and the operation hangs indefinitely.
What did you expect to see?
When reading the response body from an incomplete WebSocket handshake (where server sends handshake headers but no data afterwards), the http.Client.Timeout setting should trigger after the specified timeout duration (5 seconds in this case) while reading the body.
The text was updated successfully, but these errors were encountered: