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
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