MQTT Loop after update HA on Docker

Hi all,
I’ve updated HA on latest: Home Assistant 0.108.3
After update, I’ve noticed the MQTT connection gets connected and disconnected in loop.
On mosquitto:

1586715897: New connection from 192.168.1.13 on port 1883.
1586715897: Client home-assistant-XefilHome already connected, closing old connection.
1586715897: New client connected from 192.168.1.13 as home-assistant-XefilHome (p2, c1, k120, u'mqtt_user').
1586715897: New connection from 192.168.1.13 on port 1883.
1586715898: Socket error on client <unknown>, disconnecting.
1586715898: New connection from 192.168.1.13 on port 1883.
1586715898: Client home-assistant-XefilHome already connected, closing old connection.
1586715898: New client connected from 192.168.1.13 as home-assistant-XefilHome (p2, c1, k120, u'mqtt_user').
1586715898: New connection from 192.168.1.13 on port 1883.
1586715899: Socket error on client <unknown>, disconnecting.

It continues to reconnect.
I’ve updated the mosquitto server as well and changed the client-id to be sure there is not something wrong around using a same client-id.
Other devices gets connected and stable, and the issue appears after updating HA from 102 to this version.

Ideas what’s wrong?

Thanks!

Simon

This happens when you have 2 instances of a client with the same client id open. I had this happen on windows when I didn’t realize I already had MQTTExplorer open and tried opening another instance.

What does your mqtt config look like?

Try deleting the mqtt config part (just comment it all out with #). Restarting HA. Then bring it back in and restart again.

Hello,
Strange because I’ve changed the mqtt-id again with something new, btw I’ve tried your suggestion to commend restart and decomment and restart with no luck.

My conf:

# MQTT Broker Setup (via local Docker)
mqtt:
  broker: 192.168.1.13
  port: 1883
  client_id: home-assistant-XefilHome
  username: MYUSER
  password: MYPASSWORD
  keepalive: 120
  discovery: true
  discovery_prefix: XefilHome
  birth_message:
    topic: 'hass/status'
    payload: 'online'
  will_message:
    topic: 'hass/status'
    payload: 'offline'

Ideas?

Thanks @jocnnor !

Simon

Ok, I don’t think you have 2 instances running.

Either the username or password wrong? Or are those the real uname/password?

Also, just remove the client_id completely and let it use a randomly generated one.

If you updated mosquitto, I would assume the config got messed up, but you’re saying other devices can connect without issue. How do you know they are connected? Are you running mqttexplorer or something? Or just see the connection message in the log for the other devices.

Good morning @jocnnor ,
My steps were:

  • updated the docker image
  • restarted HA and noticed the issues in the logs of HA (constantly loop of mqtt discover)
  • stopped mosquitto, error disappear
  • started mosquitto and/or restarted HA, errors again
  • updated mosquitto, errors anyway
  • removed mqtt from HA, errors gone, readded mqtt con, errors again.

Now I’m using MQTT.js to connect manually to mosquitto and it works. I can subscribe and see the other clients. Other clients are zigbee2mqtt and one Tasmota device. Subscribing to all I can see the messages.

User/password are correct, tested and are the same for every client.

Now, removing the client-id seems to work, thanks!

I’ve a last question about zigbee2mqtt but I’ll ask on another thread.

Thank you!

Simon

Just an FYI that some people were/are experiencing issues caused by two concurrent instances of Home Assistant. It is unique to docker installations only for those who included a specific startup parameter (i.e. specified a command to start Home Assistant within the container).

https://github.com/home-assistant/core/issues/32992#issuecomment-604789778

2 Likes

So the ‘fix’ of removing the client id is only that each instance now generates its own id and it appears to work.

Hope he looks into that.

1 Like