mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

Mosquitto may fail to start on boot

Open narc-Ontakac2 opened this issue 1 year ago • 4 comments

I originally reported this to the debian bug tracker, see #1036450. Since the systemd configuration is maintained here I am now reporting it to upstream.

On my bullseye armhf Raspberry Pi the restart on reboot fails with "Cannot assign requested address". The configuration causing this is fairly simple:

$ cat /etc/mosquitto/conf.d/local.conf
listener 1883 127.0.0.1
listener 1883 192.168.47.11
password_file /etc/mosquitto/passwd

A later manual restart using

sudo service mosquitto restart

starts mosquitto correctly.

This does not happen reproducibly, but is quite serious. A power outage may bring down the whole home automation until manual intervention happens.

I have taken a closer look and found that the error is the same as with an an address that does not exist on the system. So reason is probably that the network interface with the external address is not yet up.

The easy solution would be for the service to wait for the network-online target. However the systemd documentation tells me that this is a questionable solution. It is however acceptable since mosquitto would not delay boot.

According to the above source IP_FREEBIND might be a better solution. This is however substantially harder to do.

Since this is a serious issue one of the above solutions should be implemented.

narc-Ontakac2 avatar Aug 20 '23 20:08 narc-Ontakac2