-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 input plugin disconnecting from Mosquitto #4594
Comments
I believe this is an issue in the eclipse/paho.mqtt.golang library version we are using. In the next release of Telegraf (1.8) we are using an updated version of this library, could you try using one of the If the error still occurs, can you add the Telegraf logs around the moment that Telegraf loses connection and does not attempt or is unable to reconnect? |
I downloaded nightly build and noticed the following behavior. As can be seen in Telegraf log below, it outputs twice that the MQTT Client is connected, even though I have only one MQTT consumer configuration. After some time it stops collecting metrics from MQTT broker, exactly at the point where MQTT broker Mosquitto says that there was a socket error. ------------ Mosquitto log ------------------------ In case when Telegraf log states only once "MQTT Client Connected", it seems that it works properly. In the sequel, I provide another time the same thing happened. I highlighted the time stamps where disconnection occurs. ---------- Telegraf log -------------------------------- ---------- Mosquitto log ----------------------------- |
I can confirm the aforementioned issue where the nightly build connects two times to the broker.
It also seems that the mqtt_consumer stopped gathering metrics after some hours as stated by the reference. |
Can you test if this change helps: #4846 (comment) |
We are planning to use TICK stack on a EU funded project for collection of measurements from MQTT broker. For this purpose, we setup InfluxDB, MQTT broker (Mosquitto) and Telegraf (mqtt_consumer input plugin and InfluxDB output plugin). Telegraf connects successfully to Mosquitto, and starts collecting published metrics in JSON format. However, from time to time it disconnects from the MQTT broker. After a couple of days, it stops reconnecting after losing connection and all the metrics published to MQTT broker are lost.
In the sequel, I provide you with both Telegraf and Mosquitto logs at the moment when there is a reconnection.
Telegraf log:
2018-08-26T18:07:20Z D! Output [influxdb] buffer fullness: 73 / 10000 metrics.
2018-08-26T18:07:20Z D! Output [influxdb] wrote batch of 73 metrics in 7.241577ms
2018-08-26T18:07:22Z E! Error in plugin [inputs.mqtt_consumer]: E! MQTT Connection lost
error: pingresp not received, disconnecting
MQTT Client will try to reconnect
2018-08-26T18:07:22Z I! MQTT Client Connected
2018-08-26T18:07:40Z D! Output [influxdb] buffer fullness: 76 / 10000 metrics.
2018-08-26T18:07:40Z D! Output [influxdb] wrote batch of 76 metrics in 5.022393ms
**--------------------------------------------------------------------------------------------
Mosquitto log
1535306832: Received PINGREQ from energo2
1535306832: Sending PINGRESP to energo2
.
.
.
1535306842: Sending PUBLISH to energo2 (d0, q0, r0, m0, 'ENE-E893B/data', ... (240 bytes))
1535306842: Socket error on client energo2, disconnecting.
1535306842: New connection from ::1 on port 1883.
1535306842: Client energo2 disconnected.
1535306842: New client connected from ::1 as energo2 (c0, k60, u'user1').
1535306842: Sending CONNACK to energo2 (1, 0)
**---------------------------------------------------------------------------------------------
Relevant telegraf.conf:
[[inputs.mqtt_consumer]]
servers = ["tcp://localhost:1883"]
persistent_session = true
qos = 2
connection_timeout = "120s"
topics = [
"+/data",
]
name_override = "demand"
client_id = "xxxxx"
username = "xxxx"
password = "xxxxxxxxx"
data_format = "json"
tag_keys = [
"measurementID",
"measurementIndex",
"deviceID"
]
System info:
Telegraf version 1.7.3, Ubuntu 16.04, Mosquitto ver. 1.4.14
The text was updated successfully, but these errors were encountered: