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

fix: keepalive issues #1855

Merged
merged 5 commits into from
Apr 30, 2024
Merged

fix: keepalive issues #1855

merged 5 commits into from
Apr 30, 2024

Conversation

robertsLando
Copy link
Member

@robertsLando robertsLando commented Apr 30, 2024

Actually keepalive is shifted every time a packet is written to stream. This is wrong because in cases where there is a constant publish the keepalive never triggers as it keeps being shifted preventing the timeout to trigger and to close the client.

With this PR we ensure that the keep alive timer is shifted only when we receive control packets as defined in specs: https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Ref363645900

Fixes #1727

@@ -1924,9 +1918,6 @@ export default class MqttClient extends TypedEventEmitter<MqttClientEventCallbac

this.emit('packetsend', packet)

// When writing a packet, reschedule the ping timer
this._shiftPingInterval()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root cause of the problem

mcollina
mcollina previously approved these changes Apr 30, 2024
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After mqtt client is reconnected, it is unable to continue publishing message
2 participants