Inputs.mqtt_consumer can't connect to broker

Hi,

I’m literally tearing my hair out (what little hair I have anyway!) as I cannot get Telegraf to connect to any MQTT broker. I was using Mosquitto locally but have tested public servers to rule that out yet I have exactly the same problem. I’m sure I’m doing something really stupid but I’m kind of out of ideas!

May 28 08:08:20 raspberrypi telegraf[3365]: 2020-05-28T07:08:20Z I! [inputs.mqtt_consumer] Connected [tcp://127.0.0.1:1883]
May 28 08:08:20 raspberrypi telegraf[3365]: 2020-05-28T07:08:20Z E! [inputs.mqtt_consumer] Error in plugin: connection lost: EOF
May 28 08:08:20 raspberrypi telegraf[3365]: 2020-05-28T07:08:20Z E! [inputs.mqtt_consumer] Error in plugin: subscription error: topics: : Connection lost before Subscrib

and the corresponding Mosquitto:

1590649770: New connection from 127.0.0.1 on port 1883.
1590649770: New client connected from 127.0.0.1 as Telegraf-Consumer-NalQU (c1, k60).
1590649770: No will message specified.
1590649770: Sending CONNACK to Telegraf-Consumer-NalQU (0, 0)
1590649770: Received SUBSCRIBE from Telegraf-Consumer-NalQU
1590649770: Socket error on client Telegraf-Consumer-NalQU, disconnecting.

Then using a public broker:

May 28 08:10:41 raspberrypi telegraf[3421]: 2020-05-28T07:10:41Z I! [inputs.mqtt_consumer] Connected [tcp://broker.hivemq.com:1883]
May 28 08:10:41 raspberrypi telegraf[3421]: 2020-05-28T07:10:41Z E! [inputs.mqtt_consumer] Error in plugin: connection lost: EOF
May 28 08:10:41 raspberrypi telegraf[3421]: 2020-05-28T07:10:41Z E! [inputs.mqtt_consumer] Error in plugin: subscription error: topics: : Connection lost before Subscrib

Any pointers would be greatly appreciated :slight_smile:

Cheers,
Ben

Looks to me like the MQTT server is immediately closing the connection, perhaps there is an issue with your credentials? Is there anything helpful in the server logs?

Hi Daniel,

I was having the same problem with a public MQTT broker too so I figured the problem must have been in my Telegraf config… turns out I had a single line in the conf which was still accidentally commented out (topics area which didn’t correctly close the list).

My bad and I should have noticed earlier – I think I was fixated on the socket error which was a misleading.

Cheers,
Ben

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.