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

MQTT Paho C/C++ returns disconnection after 2.5xKeepAlive #1452

Open
kunaltakalkar opened this issue Feb 20, 2024 · 2 comments
Open

MQTT Paho C/C++ returns disconnection after 2.5xKeepAlive #1452

kunaltakalkar opened this issue Feb 20, 2024 · 2 comments
Labels

Comments

@kunaltakalkar
Copy link

Describe the bug

I am using the following Libraries: paho.mqtt.c-1.3.13, paho.mqtt.cpp-1.3.2
I have set KeepAlive to 20secs.
If the internet is disconnected during the PUBLISH calls (small chunks of data), the connectionLost is received after ~50secs (2.5xKeepAlive).

To Reproduce

  1. Connect to the MQTT broker.
  2. Start sending messages.
  3. The Internet is disconnected during publish calls.
  4. Wait for disconnection (connectionLost)

Observed behavior
connectionLost is received after ~50 secs (2.5xKeepAlive)

Expected behavior
connectionLost should be received within 30 secs (1.5xKeepAlive)

Screenshots
NA

Log files
Logs are attached here:
Paho_Keepalive_Issue.txt

** Environment (please complete the following information):**

  • OS: Linux Docker (on Ubuntu 22.04.3 LTS (x86-64))
  • Version: 22.04.1-Ubuntu x86_64

Additional context
async_publish example was modified to simulate the behavior. Its attached to the ticket.
async_publish.cpp.txt

@icraggs
Copy link
Contributor

icraggs commented Mar 5, 2024

If you have a keepalive interval of 30 seconds, then if there is no other traffic, a PINGREQ will be sent every 30 seconds. If the connection is broken soon after a PINGREQ is sent and the PINGRESP received, it will be another 30 seconds until the next PINGREQ is sent. Then another 45 seconds before the connection is recognized as lost. So I think this is possible.

@kunaltakalkar
Copy link
Author

As per mqtt specification, broker follows 1.5x KeepAlive. Shouldn't that be same on the client and be consistent with the specification?
Please correct me if my understanding is wrong.

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

No branches or pull requests

2 participants