addons: Mosquitto 6.1.x with mosquitto-go-auth spams "error: received null username, ..."
Describe the issue you are experiencing
After upgrade Mosquitto add-on to 6.1.1 I’ve got a spam in add-on’s log with a line:
error: received null username, clientid or topic, or access is equal or less than 0 for acl check
error: received null username, clientid or topic, or access is equal or less than 0 for acl check
error: received null username, clientid or topic, or access is equal or less than 0 for acl check
error: received null username, clientid or topic, or access is equal or less than 0 for acl check
I enabled debug output for mosquitto and found after a message from one of external devices I always got this error. Second devices with the same bridge configuration works well. There are two lines in the debug mode:
1651663393: Received PUBLISH from wirenboard-A4JBKLBD.wb2hass (d0, q1, r1, m26535, 'wb1/devices/power_status/controls/Vin', ... (5 bytes))
error: received null username, clientid or topic, or access is equal or less than 0 for acl check
1651663393: Sending PUBACK to wirenboard-A4JBKLBD.wb2hass (m26535, rc0)
1651663393: Received PUBLISH from wirenboard-AHL3GFZO.wb2hass (d0, q1, r1, m54105, 'wb2/devices/wb-msw-v3_115/controls/Current Motion', ... (2 bytes))
1651663393: Sending PUBACK to wirenboard-AHL3GFZO.wb2hass (m54105, rc0)
It’s interesting I anyway got the data to ‘wb1/#’ topic, but also have a huge spam as I have continuous flow of data especially from wirenboard-A4JBKLBD.wb2hass (‘wb1/#’).
I found this error text in the mosquitto-go-auth plugin sources but see no reason to get this message as have no difference between device with ‘wb1/#’ and one with ‘wb2/#’ messages.
I’ve tried to add usernames for mqtt clients in the add-on config, before I used HA accounts. mosquitto spams the error anyway.
What type of installation are you running?
Home Assistant OS
Which operating system are you running on?
Home Assistant Operating System
Which add-on are you reporting an issue with?
Mosquitto broker
What is the version of the add-on?
6.1.1
Steps to reproduce the issue
- Upgrade add-on to 6.1.1
- Wait client connected.
- Read spam in the log.
Anything in the Supervisor logs that might be useful for us?
No response
Anything in the add-on logs that might be useful for us?
No response
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 25 (7 by maintainers)
So to summarize for anyone coming here facing this issue. I’m gathering that its somehow caused by old retained messages on the broker sent by software you don’t use anymore but used to. Particular software that supported Home Assistant discovery as those messages are always posted with
retain: true. Retained messages don’t expire FYI so if you’ve installed and uninstalled things that use MQTT in the past you probably have some hanging around.I don’t really know why this is as I’m not familiar enough with the internal workings of Mosquitto. I would guess some part of the credentials used to post the message are cached in these somehow but I’m really not sure.
The simple fix appears to be this:
You might be able to fix this without an uninstall if you connect to the broker with something like MQTT Explorer and specifically delete the stale retained messages. But you’d have to know which ones were stale and I’m not certain this will work as so far all users have gone the uninstall and reinstall route.
Sorry about this. Wish I knew more about why exactly this happens but at least the solution is fairly simple.
I was also experiencing this issue and found that it was due to retained or cached but unavailable mqtt entities which were being pulled in to the mqtt integration. I removed both the add-on and the mqtt integration, rebooted, and then installed the add-on and mqtt integration and the errors stopped appearing.
Well, I uninstalled addon, restart HA core, installed addon back and reconfigured MQTT integration (wrote new password for ‘homeassistant’ user). Connection to addon’s mosquitto server works well but there is nothing about new connections in the addon’s log. Is it cached somewhere in the docker container? All I see in the log for now is:
It’s about 1 hour from addon start, 3 external clients connected since (and also internal from HA integration).
It the addon /etc/mosquitto/mosquitto.conf has such lines:
But now there is no spam from mosquitto-go-auth, it’s good! 😃
So you shouldn’t have to do this but if you uninstall and reinstall the addon what happens? Does that fix the error? In chatting with another user about this I’m getting the impression there is something cached about auth that’s creating issues with the acl check. I’m working on adding some debug logging to help but after reinstalling they were able to eliminate the error.