-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[feat] Keepalive improvements #1859
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually keepalive works this way (PingTimer):
A timer is setup, when timer is elapsed it triggers a function to check if last received control message was more then our keepalive time, if ok it schedule a new check and sends a pingreq otherwise closes the connection and triggers a reconnect. Every time we receive a packet we shift the timer.
Specs say: https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Figure_3.5_Keep
In order to improve the actual implementation my idea is:
In order to do this I would pass the
client
instance to the PingTimer class (that I would rename in KeepaliveManager) and it should just expose ashift
anddestroy
method and handle above logic itself by calling client methods like checkPing (instead of providing the checkping function in constructor).In this way we would be sure that the connection is closed exaclty after 1.5*keepalive seconds without any packet
NOTE: Remeber to check timer is never greather then 32 bit or less then 0
cc @mcollina opinions/suggestions on this?
The text was updated successfully, but these errors were encountered: