Skip to content

How to test if a connection is still valid #542

Answered by SimonFrings
Sell24 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @Sell24, thanks for bringing this up 👍

In a gist: If the device you're referring to is not capable of a graceful shutdown, it will also not send an end or close event. This means that if the device "dies" for any reason, it will be unable to notify you that the connection is "dead". To determine if your communication partner is still alive, you can implement higher-level application timeout logic, such as sending a heartbeat message every once in a while. If the device is dead and does not respond to your heartbeat message, you can close the connection.

There are similar tickets also covering this aspect like reactphp/socket#193, reactphp/socket#249 and others.

Hope this helps :)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Sell24
Comment options

Answer selected by Sell24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants