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

Mosquitto 2.0.12 - Keep alive 0 results in 'identifier rejected #9763

Closed
pflugj opened this issue Sep 15, 2021 · 14 comments · Fixed by #9803
Closed

Mosquitto 2.0.12 - Keep alive 0 results in 'identifier rejected #9763

pflugj opened this issue Sep 15, 2021 · 14 comments · Fixed by #9803
Assignees
Labels
area/mqtt bug unexpected problem or unintended behavior

Comments

@pflugj
Copy link

pflugj commented Sep 15, 2021

System info:

Telegraf V1.19
Mosquitto V2.0.12

Steps to reproduce:

config:

# Configuration for MQTT server to send metrics to

[[outputs.mqtt]]

servers = ["127.0.0.1:1883"] # required.
client_id = "db-meter"
batch = true

topic_prefix = "Main_DB"
qos = 2
data_format = "influx"

Expected behavior:

Connect without error

Actual behavior:

Error connecting to output "output.mqtt": identifier rejected"

Additional info:

eclipse/mosquitto#2309

@pflugj pflugj added the bug unexpected problem or unintended behavior label Sep 15, 2021
@rukechen
Copy link

Hi all,

I face the same issue, and here is the related information https://community.influxdata.com/t/get-identifier-rejected-error-while-using-outputs-mqtt-mosquitto-version-is-2-0-12/21702/7.

Thanks

@Jayclifford345
Copy link
Collaborator

Hi all,
I can confirm this issue. When using Node Red we can successfully connect to the Mosquitto 2.0.12 .
Thanks,

@helenosheaa helenosheaa self-assigned this Sep 20, 2021
@ralight
Copy link

ralight commented Sep 21, 2021

This is a bug in Mosquitto (see eclipse/mosquitto#2117 ), but although keepalive=0 is entirely valid, I'd really suggest against using it unless you're very sure it's what you want. Having it as a default is probably not the right choice.

@helenosheaa
Copy link
Member

helenosheaa commented Sep 21, 2021

My intention is to open a PR adding keep_alive as a config option in the plugin so people can set it to a sensible default.

Previously the plugin had keep_alive set to 0 so to keep behavior consistent for users I would probably leave 0 as the default which they can then change as needed. However this is causing errors if they are using mosquitto v2.0.12, @ralight is this something that will be fixed in the next eclipse/mosquitto release?

@ralight
Copy link

ralight commented Sep 22, 2021

@helenosheaa Yes of course - it's already fixed in the repo and will be part of the next release, which should be by the end of the month.

@helenosheaa
Copy link
Member

@ralight great thanks!

@helenosheaa
Copy link
Member

helenosheaa commented Sep 22, 2021

@pflugj @rukechen, i've added a keep_alive config option to the plugin in this PR so you can work around this if you are trying to use v2.0.12, if you would like to test it out from a build or it will be in the next bugfix release.

I've tested it using v2.0.10 and v.2.0.12 and worked for both.

@pflugj
Copy link
Author

pflugj commented Sep 25, 2021

@helenosheaa @ralight and everybody else here working for us "users"
THANKS for your help and efforts!!
...unfortunately I am to stupid to test the fixes until a new release is available through the update channels :-(

@helenosheaa
Copy link
Member

No problem! I'll ping you when it's released.

If you change your mind you'll just download the relevant build artifact from the list here.

Then run that downloaded telegraf with your config. Within your config set (or your desired keep_alive). Should work for any mosquitto version.

[[outputs.mqtt]]
keep_alive = 30

@DavidAntliff
Copy link

DavidAntliff commented Nov 15, 2021

@helenosheaa is this fixed in telegraf 1.20.3 / mosquitto 2.0.13? I'm just using default values for keep_alive and many of my MQTT clients are being rejected with "(2) identifier rejected" errors. If I roll mosquitto back to 2.0.11 then it's working fine for me. Strange thing is that the connections are rejected even if telegraf is not running - so is this just a mosquitto issue?

EDIT: I see now that this relates to publishing to mosquitto, which telegraf can be configured to do. In my case, I'm not publishing to mosquitto from telegraf, but I am publishing via a third-party C++ client, so it's perhaps a similar issue?

@helenosheaa
Copy link
Member

helenosheaa commented Nov 15, 2021

You'll need to set keep_alive to something other than 0 which is the default as that was previous working behavior e.g. keep_alive = 30

IIRR switching keep_alive off was an issue with mosquitto 2.0.12 it may still be an issue in mosquitto 2.0.13.

Let me know if that works.

@DavidAntliff
Copy link

@helenosheaa thanks for your response and sorry for the noise - my issue wasn't directly a telegraf issue, but it's very related to this one I think.

I set the client keep_alive to non-zero in my client (mqtt_cpp) and this did in fact resolve the issue. I can confirm that it is still an issue for mosquitto 2.0.13.

I'm not sure how "switching keep_alive off" relates to setting it to non-zero - do you mean switching it off in mosquitto broker, as opposed to setting it non-zero in the client? These are two different things, is that right?

@ralight
Copy link

ralight commented Nov 15, 2021

@DavidAntliff since it was introduced the max_keepalive option in mosquitto has had a default value of 65535. This did not apply to the case where a client was passing keepalive=0 (infinite keepalive), even though it should have. This was fixed, but the resulting problem was that max_keepalive could not be set to 0 either, which meant using earlier versions of telegraf was not possible.

If you want your client to use keepalive=0 then you must set max_keepalive 0 in the mosquitto configuration file.

@DavidAntliff
Copy link

@ralight thank you - I did get there eventually, it wasn't until I saw the updated comment in the 2.0.13 default mosquitto.conf that I figured out what you've just said.

So, yes, I can confirm that 2.0.13 is now working for me, either with non-zero keepalive for clients, or by setting max_keepalive 0 in the mosquitto config file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mqtt bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants