websocketpp
                                
                                
                                
                                    websocketpp copied to clipboard
                            
                            
                            
                        Internet disconnection on the client side
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?
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.
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)