Mosquitto broker Add-on is not initialized correctly when HA starts

Hi everyone,

I’ve run into the problem with Mosquitto broker Add-on. When I restart the OS the add-on doesn’t start correctly. It shows the following errors in the log:

[cont-init.d] executing container initialization scripts...
[cont-init.d] mosquitto.sh: executing...
parse error: Expected string key before ':' at line 1, column 4
[08:21:01] ERROR: Unknown HTTP error occured
[08:21:04] INFO: SSL is not enabled

and

[08:21:09] INFO: Starting mosquitto MQTT broker...
1660713669: Warning: Mosquitto should not be run as root/administrator.
parse error: Expected string key before ':' at line 1, column 4
[08:21:13] ERROR: Unknown HTTP error occured
[08:21:13] INFO: Successfully send discovery information to Home Assistant.

Because Mosquitto broker starts with errors the other add-ons which depends on Mosquitto also start with errors (for example Zigbee2Mqtt).

However if I login to HA web-interface after HA has been fully initialized and manually restart the Mosquitto broker (through Settings->Add-ons menu) then the add-on starts without any error and it begins to operate in normal mode. And then I restart other add-ons (Z2M etc) and they also start working as expected. So to summarize: Mosquitto broker starts normally only from the second attempt.

I was able to reproduce the problem on three devices – one is Raspberry Pi 4 and two are running under Armbian. So it seems that we problem is not device-specific. Also I suspect that the problem began when I’ve upgraded OS from Focal to Jammy through the command do-release-upgrade.

I use HA in Supervised mode.

I did some debugging with cont-init.d/mosquitto.sh and found that the error occurs when script tries to execute bashio::config command. Next I looked at addons/core/mosquitto/config.yaml and found that 1st line of it contained three defis symbols ‘-‘. It is very close interconnected with the error message “parse error: Expected string key before ‘:’ at line 1, column 4”. I’ve tried to remove this 1st line however it seems that the file addons/core/mosquitto/config.yaml is restored from somewhere (Git?) every time HA starts.

I would like to disable auto-update for file addons/core/mosquitto/config.yaml (or for some upper folder) just to validate my assumption. How to do it?

Thanks in advance.

There might be something wrong with your configuration. Can you post the correctly formatted yaml version here (available in the 3 dot icon on the addon configuration page).

I use only default settings. Just to be sure I couple times made “Reset to defaults”, unfortunately it didn’t help…

logins: []
require_certificate: false
certfile: fullchain.pem
keyfile: privkey.pem
customize:
  active: false
  folder: mosquitto

Yeah that’s fine. You should open a new issue here:

Thanks, I raised an issue in the GitHub:

Will continue discussion there…

2 Likes