Skip to content

fix: keepalive issues#1855

Merged
robertsLando merged 5 commits into
mainfrom
ping-improvements
Apr 30, 2024
Merged

fix: keepalive issues#1855
robertsLando merged 5 commits into
mainfrom
ping-improvements

Conversation

@robertsLando
Copy link
Copy Markdown
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

@robertsLando robertsLando requested a review from mcollina April 30, 2024 09:00
Comment thread src/lib/client.ts
this.emit('packetsend', packet)

// When writing a packet, reschedule the ping timer
this._shiftPingInterval()
Copy link
Copy Markdown
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
Copy Markdown
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