Skip to content

Implement server PING to check client health #36

@mxafi

Description

@mxafi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions