Mosquitto suddenly stopped working

A couple of hours ago, without any restarts or updates taking place, Home Assistant suddenly stopped controlling my Zigbee devices. I discovered that I could control them directly in the Zigbee2MQTT UI, so the problem appeared to be in the Mosquitto add-on.

I checked if it had stopped and needed to be restarted, but apparently if there’s an update available (which there was), the start/stop/restart UI isn’t there. So I installed the update, the add-on started up, and I still didn’t have control of any MQTT devices.

I never looked in the Mosquitto log in the past so I don’t know if what I’m seeing now is normal, but I suspect it’s not. But I’m not sure how to fix it since I didn’t change anything to cause it to stop working. The “protocol error” and “not authorized” parts sound a bit suspicious.

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/mosquitto.sh
[21:13:28] INFO: SSL is not enabled
cont-init: info: /etc/cont-init.d/mosquitto.sh exited 0
cont-init: info: running /etc/cont-init.d/nginx.sh
cont-init: info: /etc/cont-init.d/nginx.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun mosquitto (no readiness notification)
services-up: info: copying legacy longrun nginx (no readiness notification)
[21:13:29] INFO: Starting NGINX for authentication handling...
[21:13:29] INFO: Starting mosquitto MQTT broker...
2023-09-05 21:13:29: Warning: Mosquitto should not be run as root/administrator.
2023-09-05 21:13:29: mosquitto version 2.0.17 starting
2023-09-05 21:13:29: Config loaded from /etc/mosquitto/mosquitto.conf.
2023-09-05 21:13:29: Loading plugin: /usr/share/mosquitto/go-auth.so
2023-09-05 21:13:29:  ├── Username/password checking enabled.
2023-09-05 21:13:29:  ├── TLS-PSK checking enabled.
2023-09-05 21:13:29:  └── Extended authentication not enabled.
s6-rc: info: service legacy-services successfully started
2023-09-05 21:13:29: Opening ipv4 listen socket on port 1883.
2023-09-05 21:13:29: Opening ipv6 listen socket on port 1883.
2023-09-05 21:13:29: Opening websockets listen socket on port 1884.
2023-09-05 21:13:29: mosquitto version 2.0.17 running
2023-09-05 21:13:29: New connection from 127.0.0.1:48576 on port 1883.
2023-09-05 21:13:29: Client <unknown> disconnected due to protocol error.
2023-09-05 21:13:29: New connection from 172.30.32.1:45268 on port 1883.
error: received null username or password for unpwd check
2023-09-05 21:13:29: Client 241bc52c disconnected, not authorised.
[21:13:29] INFO: Successfully send discovery information to Home Assistant.
[21:13:30] INFO: Successfully send service information to the Supervisor.
2023-09-05 21:13:30: New connection from 172.30.33.6:49752 on port 1883.
2023-09-05 21:13:30: New client connected from 172.30.33.6:49752 as mqttjs_1a4b37b1 (p2, c1, k60, u'addons').
2023-09-05 21:13:34: New connection from 172.30.32.1:45284 on port 1883.
error: received null username or password for unpwd check
2023-09-05 21:13:34: Client fa4863ad disconnected, not authorised.
2023-09-05 21:13:34: New connection from 172.30.32.1:45286 on port 1883.
error: received null username or password for unpwd check
2023-09-05 21:13:34: Client 241bc52c disconnected, not authorised.
2023-09-05 21:13:37: New connection from 172.30.32.1:44371 on port 1883.
2023-09-05 21:13:37: New client connected from 172.30.32.1:44371 as 7JZlt64nRtqxqXxEpMagjh (p2, c1, k60, u'homeassistant').
2023-09-05 21:13:37: Outgoing messages are being dropped for client 7JZlt64nRtqxqXxEpMagjh.
2023-09-05 21:13:39: New connection from 172.30.32.1:45302 on port 1883.
error: received null username or password for unpwd check
2023-09-05 21:13:39: Client fa4863ad disconnected, not authorised.
2023-09-05 21:13:39: New connection from 172.30.32.1:43778 on port 1883.
error: received null username or password for unpwd check
2023-09-05 21:13:39: Client 241bc52c disconnected, not authorised.

There’s nothing unusual in that log. This is a normal heartbeat check from the supervisor:

2023-09-05 21:13:39: New connection from 172.30.32.1:43778 on port 1883.
error: received null username or password for unpwd check
2023-09-05 21:13:39: Client 241bc52c disconnected, not authorised.

See if you can connect to the broker with MQTT Explorer (free).

Looks like I can.

image

Looking at one of the affected Zigbee devices (an Inovelli Blue dimmer) in the Home Assistant UI shows some controls (such as on/off) grayed out and shows some sensors which previously had meaningful names as “MQTT sensor”. Those properties appear correctly in the Zigbee2MQTT UI.

image
image

I reckon your broker is ok. Investigate the connection between zigbee2qtt and the broker. Or just try restarting it.

And check your zigbee2mqtt logs.

Someone else with a similar issue:

check the password of the MQTT Broker.

Hi there, yesterday I hat a similar issue. MQTT - / Zigbee2MQTT where running, no connection zu HA. In my case, the password for the MQTT Broker was changed, I don’t know how, but it was my master password instead of the broker password.
So I recharged the password for the broker and the systems is no running .

I think my situation may be different because upon further investigation, it seems that a lot of the Zigbee functionality is working. I have sensors that are reporting perfectly fine, for example. I just don’t have the switch on/off properties, and some properties don’t have the right names, as shown in my previous post.

And as far as I can tell, I don’t have anything in the logs about Z2M not being able to connect to MQTT, but I’ll check again.

Ok, I’m even more confused now. The sensors which were definitely working last night after I noticed the problem are no longer working. So I decided to look into the password thing, but it looks like I never entered any password when I first set this up. I’m not an MQTT expert so I’m not sure what I’m missing here…

I have this:

afbeelding

I did just find this in Z2M’s configuration.yaml. This is definitely not the username and password I’m using to connect from MQTT Explorer. Does setting it on the configuration screen as posted above override whatever is in this file?

image

for me it did

Well, I set the username and password in the Z2M configuration, restarted Z2M and reloaded the MQTT integration. My devices still don’t work, but it looks like Z2M is connecting to Mosquitto…?

Zigbee2MQTT:info  2023-09-06 09:12:55: Connecting to MQTT server at mqtt://core-mosquitto:1883
Zigbee2MQTT:info  2023-09-06 09:12:56: Connected to MQTT server
Zigbee2MQTT:info  2023-09-06 09:12:56: MQTT publish: topic 'zigbee2mqtt/bridge/state', payload '{"state":"online"}'
Zigbee2MQTT:info  2023-09-06 09:12:57: Started frontend on port 0.0.0.0:8099

Interestingly, the Zigbee sensors are working again, but the switches are still missing their on/off controls. And the sensors don’t have their correct names for battery and temperature.

Look in the frontend under log what is happening

Maybe because of https://github.com/Koenkk/zigbee2mqtt/issues/18445

I had noticed that I was still on a 2023.7 version of Home Assistant, so I just updated to 2023.8.4. This appears to have fixed the name issues, but the on/off controls for the switches are still grayed out. There’s defintely communication, though, because they report, for example, power correctly.

image
image

Hm. and when you remove the batteries from the switches and reconnect with Z2M again? I had some problems by running the OTA, after removing the batteries, the OTA was running.
maybe it helps.

Did you try to switch one (at the switch)? This should send a status update.

I think my problem is a MQTT Broker problem. Mabey you have the same issue.

My Zigbee dongle is still sending data to Z2M but stops with the connection to MQTT Broker.

Zigbee2MQTT:error 2023-09-06 19:41:43: Not connected to MQTT server!
Zigbee2MQTT:error 2023-09-06 19:41:43: Cannot send message: topic: ‘zigbee2mqtt/Aqara Pavillon Fugt Temp’, payload: '{“battery”:100,“humidity”:72.5,“linkquality”:31,“pressure”:1068,“temperature”:19.53,“voltage”:3035}
Zigbee2MQTT:error 2023-09-06 19:41:44: Not connected to MQTT server!
Zigbee2MQTT:error 2023-09-06 19:41:48: Not connected to MQTT server!
Zigbee2MQTT:error 2023-09-06 19:41:48: Cannot send message: topic: ‘zigbee2mqtt/Kontor lys sensor’, payload: '{“battery”:100,“illuminance”:8417,“illuminance_lux”:7,“led_indication”:true,“linkquality”:31,“motion_sensitivity”:“medium”,“occupancy”:true,“occupancy_timeout”:0,“temperature”:23.05,“update”:{“state”:“idle”},“update_available”:false}
Zigbee2MQTT:error 2023-09-06 19:41:54: Not connected to MQTT server!
Zigbee2MQTT:error 2023-09-06 19:41:54: Cannot send message: topic: ‘zigbee2mqtt/Kontor lys sensor’, payload: '{“battery”:100,“illuminance”:8417,“illuminance_lux”:7,“led_indication”:true,“linkquality”:31,“motion_sensitivity”:“medium”,“occupancy”:false,“occupancy_timeout”:0,“temperature”:23.05,“update”:{“state”:“idle”},“update_available”:false}
Zigbee2MQTT:error 2023-09-06 19:41:54: Not connected to MQTT server!
Zigbee2MQTT:error 2023-09-06 19:42:04: Not connected to MQTT server!
Zigbee2MQTT:error 2023-09-06 19:42:14: Not connected to MQTT server!
Zigbee2MQTT:error 2023-09-06 19:42:15: Not connected to MQTT server!