-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
timeout errors are unrecoverable #11
Comments
It is not idiomatic to poll connections with timeouts in Go. Close the websocket connection one minute after writing the close message. This will cause a blocked reader to return with an error. |
Recoverable timeouts are difficult to implement. I am not aware of other Go network protocol libraries that support recoverable timeouts. The application can implement timeout polling in a net.Conn shim between the websocket.Conn and the underlying net.Conn. A sketch for creating the shim is:
|
Once websocket.nextReader returns a timeout error it will always do so. That makes it impossible to poll a websocket and periodically check whether the socket should be closing or something like that. Basically what I wanted to do is to have the sender set a flag when it sends a close message and have the reader continue reading until a one minute timeout is reached. What I tried is below, but perhaps there's a much more elegant way to do this?
The text was updated successfully, but these errors were encountered: