Skip to content
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

fix bug: issue #341 #342

Closed
wants to merge 1 commit into from
Closed

fix bug: issue #341 #342

wants to merge 1 commit into from

Conversation

yihexi
Copy link

@yihexi yihexi commented Jun 2, 2022

fix bug :
Dial got error "failed to WebSocket dial: response body is not a io.ReadWriteCloser: *http.cancelTimerBody" when set http.DefaultClient.Timeout #341

if http.DefaultClient.Timeout is set, resp.Body will be a *http.cancelTimeBody. it is an io.ReadCloser. and dial will be failed.
@yihexi yihexi requested a review from nhooyr as a code owner June 2, 2022 02:49
@lexuzieel
Copy link

Just got the same error when I was using http.DefaultClient prior to dialing a websocket connection.
I solved it by creating my own *http.Client instance and setting Timeout there:

httpClient := &http.Client{
  Timeout: 10 * time.Second,
}

@nhooyr
Copy link
Owner

nhooyr commented Mar 7, 2023

@MajorLettuce That shouldn't have worked either though. DefaultClient is a *http.Client.

@yihexi This code won't compile, we need to be able to write to the connection.

@nhooyr nhooyr closed this Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants