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
Client keep_alive must be non-zero to connect to default mosquitto 2.0.13 #904
Comments
I can confirm that the issue is with the default value of the client's keep_alive. By setting this to a non-zero value, mqtt_cpp is able to connect to mosquitto 2.0.12 and 2.0.13.
What I'm not sure about is whether this is intended behaviour by mosquitto, or a bug. I've asked for clarification from the mosquitto project. EDIT: turns out this is intended behaviour, and you must set |
I've worked out what's going on and my summary is here. Since it would break existing projects to change the default keepalive in mqtt_cpp, you might want to consider advising in your README for users to change the default value of keep_alive to non-zero if they want it to work out-of-the-box with mosquitto 2.0.13 or newer (or change the mosquitto config), otherwise many of your new users who try to use it with mosquitto are going to run into this problem quickly and potentially move onto other libraries when it doesn't work. |
But is this going to be fixed in mosquitto ? Because this does sound a bit like this is a mosquitto issue. I think a default of no keep alive for a client is quite reasonable. |
@kleunen I tried to get an answer to that back in November but failed (see my link above) - from what I can tell it's an intentional change in mosquitto to prohibit no-keep-alive clients by default. Maybe there was a security incident behind it, I really don't know. I reported this here because this great library doesn't work out-of-the-box with mosquitto any more and it's a non-trivial exercise to determine why. Maybe @ralight can advise? |
Yes it would be good to understand the reason behind why mosquitto is rejecting these clients. I am not saying at this moment we should not add this to the documentation of mqtt_cpp. But at least this behaviour should be documented in the mosquitto documentation. Because not only mqtt_cpp is effected but any client having no keep alive (by default). |
Hi, I've been happily using this library with mosquitto 2.0.11 for a few months.
I've recently attempted to update to mosquitto 2.0.12 & 2.0.13 and run into a connection problem. The server is rejecting client connections with error 2 (identifier_rejected).
I'm using commit 29f93bc (and was previously using 70e45c2, which has the same issue).
Mosquitto broker log:
In my
client->set_connack_handler(bool sp, mqtt::connect_return_code connack_return_code)
callback I'm gettingsp
isfalse
, andconnack_return_code
is 2, oridentifier_rejected
.I don't personally understand the exact issue, so I'm bringing it to your attention because some other client implementations have had the same issue lately, and you might better understand the implications:
telegraf: https://community.influxdata.com/t/get-identifier-rejected-error-while-using-outputs-mqtt-mosquitto-version-is-2-0-12/21702
micropython: https://forum.micropython.org/viewtopic.php?t=11076&p=60836
Perhaps this is also relevant? A breaking change in mosquitto for a zero keepalive value sent by a client?
eclipse/mosquitto#2117
For now I can remain with mosquitto 2.0.11 but if you'd like me to test any changes against 2.0.12 or 2.0.13 I can do this fairly easily at the moment.
The text was updated successfully, but these errors were encountered: