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

[BUG] <title>Mobile phone actively disconnects from the network, websocket server cannot obtain close event #962

Open
1 task done
XuruiPro opened this issue Sep 24, 2024 · 1 comment
Labels

Comments

@XuruiPro
Copy link

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

  1. Run the WS server, print the information in the SetCloseHandler on the server, and retrieve the incorrect information in the ReadMessage judgment
  2. Android phone links to ws server
  3. Shut down all networks on Android
  4. The ws server did not print any messages

Anything else?

No response

@XuruiPro XuruiPro added the bug label Sep 24, 2024
@XuruiPro XuruiPro changed the title [BUG] <title>Mobile phone actively disconnects, websocket server cannot obtain shutdown event [BUG] <title>Mobile phone actively disconnects from the network, websocket server cannot obtain shutdown event Sep 24, 2024
@XuruiPro XuruiPro changed the title [BUG] <title>Mobile phone actively disconnects from the network, websocket server cannot obtain shutdown event [BUG] <title>Mobile phone actively disconnects from the network, websocket server cannot obtain close event Sep 24, 2024
@hulkingshtick
Copy link

hulkingshtick commented Sep 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants