[BUG] <title>Mobile phone actively disconnects from the network, websocket server cannot obtain close event
Opened this issue · 1 comments
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
When connecting to the websocket server on a mobile phone and directly shutting down the network, neither the SetCloseHandler nor ReadMessage can listen for shutdown events or error messages @
Expected Behavior
Connect your phone to the WebSocket server and directly shut down the network to listen for client exit events
Steps To Reproduce
- Run the WS server, print the information in the SetCloseHandler on the server, and retrieve the incorrect information in the ReadMessage judgment
- Android phone links to ws server
- Shut down all networks on Android
- The ws server did not print any messages
Anything else?
No response
The close handler is called in response to a close message, not to a disconnect event. Unless your application flushes messages before echoing the close message, SetCloseHandler is not for your application. Refer to the documentation for more details.
ReadMessage returns an error when the peer closes the underlying TCP connection, the peer sends a close message, or the read deadline is exceeded. Set a read deadline to ensure that last of these conditions triggers. The example applications in this repository show how to use the read deadline.
This issue provides no evidence that there's a bug in the package.