Skip to content

Fix: reset keep alive timer only when sending data to the broker

Compare
Choose a tag to compare
@Namoshek Namoshek released this 19 Jun 13:00
· 11 commits to 0.1 since this release
e4b5f47

The MQTT v3.1 specification states that clients need to send at least one data-related message within the defined Keep Alive Interval (which is returned by the broker during the connection handshake). If no such message has been sent, the client MUST send a PINGREQ instead. Otherwise, the broker closes the connection.

Due to the way the MQTT client was resetting the ping timer whenever a message was received from the broker, subscribe-only applications utilizing the QoS Level 0 could run into disconnects. This happened because the client never sent an acknowledgement for the QoS 0 messages and also never sent a Ping Request because the Keep Alive Timer was reset on every received published messages.

This patch fixes the issue by resetting the Keep Alive Timer only whenever data is sent to the broker. More details in #5.