-
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
CloseHandler not called #325
Comments
This is expected. The close handler is called when a close message is received from the peer. The peer did not send a close message. What does the application do in the close handler? Most applications should handle close messages as part of their normal error handling. Applications should only set a close handler when the application must perform some action before sending a close message back to the peer. |
I was confused because I thought that close handler was called whatever the cause of close. |
If you are communicating with the server using the websocket protocol, then you may find this code to be helpful. |
Great helpful code, thanks. |
Hi,
My server is reading data looping on
ws.NextReader()
.The client opens the websocket like this:
conn, rsp, err := websocket.DefaultDialer.Dial(u.String(), nil)
.When it closes the websocket
conn.Close()
, the server is not correctly notified.ws.NextReader()
returns:But CloseHandler is not called.
The text was updated successfully, but these errors were encountered: