influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.59k stars 5.56k forks source link

MQTT Consumer: persistent session is not working because of random clientId #797

Closed noonowl71 closed 8 years ago

noonowl71 commented 8 years ago

I'm trying to set up a MQTT subscription with QOS 2 (mosquitto broker), which means the broker should keep messages when subscriber is offline, and send all stored messages when the subscriber becomes online.

Well, this is not working because Telegraf uses a random clientId to connect to the broker, and this causes that the persistent session is different every time it connects. From the mosquitto docs:

Badly designed clients may set clean session to false whilst using a randomly generated client id.

I think the best is to create a config option to override the clientId

sparrc commented 8 years ago

yep, that's a bug, thanks for the report

sparrc commented 8 years ago

it's worth noting that we're also setting clean session to true currently, so they wouldn't be delivered anyways.

We probably need to provide an option to set clean option to false and specify the client ID. (if clean option is set to false user must specify a client ID)

noonowl71 commented 8 years ago

That should do it, thanks!