Skip to content

document http client must use context timeout and not timeout on struct #341

Closed
@yihexi

Description

@yihexi

when I set http.DefaultClient.Timeout = time.Second * 10, websocket.Dial will get an error "failed to WebSocket dial: response body is not a io.ReadWriteCloser: *http.cancelTimerBody"

verson: nhooyr.io/websocket v1.8.7

this is because in the dial.go line 128: rwc, ok := respBody.(io.ReadWriteCloser), it convert respBody to an io.ReadWriteCloser, I think it should be rwc, ok := respBody.(io.ReadCloser).

in general, respBody is a *http.readWriteCloserBody, but if http.DefaultClient.Timeout is set, it will be a *http.cancelTimerBody, which is just an io.ReadCloser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions