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

Internet disconnection on the client side #695

Open
Nitya05 opened this issue Dec 19, 2017 · 2 comments
Open

Internet disconnection on the client side #695

Nitya05 opened this issue Dec 19, 2017 · 2 comments

Comments

@Nitya05
Copy link

Nitya05 commented Dec 19, 2017

Is there a way for the client to know that the internet on its side has got disconnected, so that it should stop sending data to the server and in turn, try to create a new connection with the server as soon as the internet is connected again.

In cases, where there is no internet, the on_fail() / on_close() api(s) do not get triggered, and hence the client continues to send data.

Are there any heartbeat or keepalive messages that can be used to check if the internet connection is still on?

@ErYcKsg
Copy link

ErYcKsg commented Dec 19, 2017

I have the same problem.

I don't know how to detect when the websocket connection has been lost due to a disconnection of the network cable for example.

I would need some way to do this check also with websocket connection.

@zaphoyd
Copy link
Owner

zaphoyd commented Dec 19, 2017

you'll generally need to write some data to the socket in order to detect a disconnect. The WebSocket protocol has a ping message that you can send that can be used to detect liveness without transmitting any data messages.

In WebSocket++ you can send pings with connection::ping. The results will come either as a close handler resulting from the TCP bad pipe or you can register a pong timeout handler that will let you know as soon as the expected reply from the other end is late (for whatever definition of late that you configure)

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

3 participants