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

Read context expiring closes websocket #294

Closed
joaohaas opened this issue Apr 8, 2021 · 3 comments
Closed

Read context expiring closes websocket #294

joaohaas opened this issue Apr 8, 2021 · 3 comments

Comments

@joaohaas
Copy link

joaohaas commented Apr 8, 2021

ctx, _ := context.WithDeadline(mdm.ctx, time.Unix(0, 0))
_, _, err = ws.Read(ctx)  // failed to get reader: context deadline exceeded
_, _, err = ws.Read(context.Background())  // failed to get reader: WebSocket closed: read timed out: context deadline exceeded

From my understanding, the first context expiring is causing the websocket to close, which I believe is not correct. The same happens if you try to write after the first read, which is the use case I need (read until a timeout, and then send a message).

If this is the expected behaviour would be great to at least have it documented.

@joaohaas joaohaas changed the title Read propagates context Read context expiring closes websocket Apr 8, 2021
@joaohaas
Copy link
Author

joaohaas commented Apr 8, 2021

Probably is somehow related to this issue:
#289

@joaohaas
Copy link
Author

joaohaas commented Apr 8, 2021

Huh, just saw #242, should've checked closed tickets before.

Really unfortunate, I really like using contexts for stuff.

Closing this.

@joaohaas joaohaas closed this as completed Apr 8, 2021
@nhooyr
Copy link
Owner

nhooyr commented Apr 10, 2021

Yea sorry it's documented in the dev branch but that hasn't made it to master yet. #256

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

No branches or pull requests

2 participants