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

[question] how keepaliveLimit works #1020

Open
thk61159 opened this issue Dec 9, 2024 · 4 comments
Open

[question] how keepaliveLimit works #1020

thk61159 opened this issue Dec 9, 2024 · 4 comments
Labels

Comments

@thk61159
Copy link

thk61159 commented Dec 9, 2024

Based on the documentation stating that keepaliveLimit 0 means "no limit," does this imply that a client session will remain active even if no PINGREQ is sent by the client? However, I still encounter clientError with a keepalive timeout message, and the client session disconnects randomly. Why is this happening?

@Gianluca-Casagrande-Stiga
Copy link
Contributor

Hi, the keepalive timeout is always set and managed by the client.
The keepalive limit can be used if you want to set a limit on the broker side on the client keepalive setting: if the client tries to connect with a longer keepalive, the client connection is blocked.
One reason to use it is to force all the clients to send a ping with a certain frequency, otherwise their connection instance will be dropped.

@thk61159
Copy link
Author

thk61159 commented Dec 9, 2024

Thank you for the explanation! After reviewing the MQTT.js client source code (github.com/mqttjs/MQTT.js), I now understand your points better. I do have another question: If keepaliveLimit is set to 0, does that restrict PINGREQ messages from being received or PINGRESP messages from being sent? If not, why would a keepalive timeout occur on the client side? For context, our client is using a keepalive of 20 seconds to connect to the broker.

@Gianluca-Casagrande-Stiga
Copy link
Contributor

If the keepalive is 20sec, your client should send the ping at least each 20sec. The broker has an inner 1.5x tolerance, so if the ping doesn't arrive in 30sec, the keep alive timeout error is thrown.
I think that your client is missing the ping to be sent or there is a connection issue that doesn't let the ping arrive. You can add a log on the broker side for the ping event, to debug the issue

@thk61159
Copy link
Author

thk61159 commented Dec 9, 2024

I will give it a try. Thank you very much for your suggestions.

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