MQTT Connect / Disconnect Loop

Upgraded Hassbian to 0.48 from 0.46 via:

$ sudo apt-get update
$ sudo apt-get -y upgrade

$ sudo systemctl stop [email protected]
$ sudo su -s /bin/bash homeassistant
$ source /srv/homeassistant/bin/activate
$ pip3 install --upgrade homeassistant
$ exit
$ sudo systemctl start [email protected]

Which broke MQTT

I found some links that mentioned apt-get update/upgrade breaks Mosquitto’s ability to auto start on boot.

Fixed that via:
sudo systemctl enable mosquitto.service
sudo systemctl start mosquitto.service

Which fixed things somewhat, the sensors reapear and report data but MQTT seems to be stuck in a loop of opening and closing the connection so the sensors connect/disconnect repeatedly.

Jul 03 16:37:15 hassbian mosquitto[423]: 1499121435: Client sensornode1 disconnected.
Jul 03 16:37:15 hassbian mosquitto[423]: 1499121435: New client connected from 192.168.1.206 as sensornode1 (c1, k15, u’pi’).
Jul 03 16:37:19 hassbian mosquitto[423]: 1499121439: New connection from 192.168.1.20 on port 1883.
Jul 03 16:37:19 hassbian mosquitto[423]: 1499121439: Client sensornode1 already connected, closing old connection.
Jul 03 16:37:19 hassbian mosquitto[423]: 1499121439: Client sensornode1 disconnected.
Jul 03 16:37:19 hassbian mosquitto[423]: 1499121439: New client connected from 192.168.1.20 as sensornode1 (c1, k15, u’pi’).
Jul 03 16:37:20 hassbian mosquitto[423]: 1499121440: New connection from 192.168.1.206 on port 1883.
Jul 03 16:37:20 hassbian mosquitto[423]: 1499121440: Client sensornode1 already connected, closing old connection.
Jul 03 16:37:20 hassbian mosquitto[423]: 1499121440: Client sensornode1 disconnected.
Jul 03 16:37:20 hassbian mosquitto[423]: 1499121440: New client connected from 192.168.1.206 as sensornode1 (c1, k15, u’pi’).

Any idea how I fix this?

Figured it out,

For some reason the OTA update username in the BRUH sensor code matters after the update where it didn’t before.

Can you tell what you changed i am also stuck in error

New connection from 192.168.0.211 on port 1883.
Sep 13 13:52:57 HA mosquitto[30869]: 1505335977: Socket error on client <unknown>, disconnecting.
Sep 13 13:52:58 HA mosquitto[30869]: 1505335978: New connection from 192.168.1.21 on port 1883.
Sep 13 13:52:58 HA mosquitto[30869]: 1505335978: Client home-assistant-1 already connected, closing old connection.
Sep 13 13:52:58 HA mosquitto[30869]: 1505335978: Client home-assistant-1 disconnected.
Sep 13 13:52:58 HA mosquitto[30869]: 1505335978: New client connected from 192.168.0.211 as home-assistant-1 (c1, k60, u'username').

I had to change the OTA update username to something different.

Oh i just check you are on hasbian. My setup is on All in one… Will it also effect i don’t see any OTA name. I tried changing name for MQTT server but still same.

Can anyone help with the MQTT Error - All was working fine before update. I have reverted back to 0.51 but still getting error -

New connection from 192.168.0.211 on port 1883.
Sep 13 13:52:57 HA mosquitto[30869]: 1505335977: Socket error on client <unknown>, disconnecting.
Sep 13 13:52:58 HA mosquitto[30869]: 1505335978: New connection from 192.168.1.21 on port 1883.
Sep 13 13:52:58 HA mosquitto[30869]: 1505335978: Client home-assistant-1 already connected, closing old connection.
Sep 13 13:52:58 HA mosquitto[30869]: 1505335978: Client home-assistant-1 disconnected.
Sep 13 13:52:58 HA mosquitto[30869]: 1505335978: New client connected from 192.168.0.21 as home-assistant-1 (c1, k60, u'username').

I am using HA all in one.

I changed the code in the Bruh Code, not Hass. Now that I’m looking back I believe commented out the OTA. It’s been awhile.

What you are seeing is a duplicate MQTT client ID attempting to connect to the broker. Make sure all your devices have a unique MQTT client ID.

1 Like