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

Implement server PING to check client health #36

Open
mxafi opened this issue Mar 1, 2024 · 0 comments
Open

Implement server PING to check client health #36

mxafi opened this issue Mar 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@mxafi
Copy link
Owner

mxafi commented Mar 1, 2024

RFC 2812:

The PING command is used to test the presence of an active client or
server at the other end of the connection. Servers send a PING
message at regular intervals if no other activity detected coming
from a connection. If a connection fails to respond to a PING
message within a set amount of time, that connection is closed. A
PING message MAY be sent even if the connection is active.

We would need to keep track of the timestamp of the last command sent by a client. We could then check the elapsed time on every pollout event for that client, and if the elapsed time is too long, send a PING command to the client. Then we would have a flag requirePong, and a timestamp for our sent PING. If the requirePong is true, we would check the elapsed time since PING was sent. If the elapsed time is over the timeout period, disconnect and inform others, if not, check if the command is PONG, if it is, flip the requirePong to false.

@mxafi mxafi added the enhancement New feature or request label Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant