Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mosquitto may fail to start on boot #2878

Open
narc-Ontakac2 opened this issue Aug 20, 2023 · 2 comments
Open

Mosquitto may fail to start on boot #2878

narc-Ontakac2 opened this issue Aug 20, 2023 · 2 comments

Comments

@narc-Ontakac2
Copy link

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.

@Wikibear
Copy link

From:
After=network.target
Wants=network.target
To:
After=network-online.target
Wants=network-online.target

Will exactly do the trick. After reboot mosquitto is running without error.

LocutusOfBorg pushed a commit to LocutusOfBorg/mosquitto that referenced this issue Sep 29, 2023
@jo-so-nx
Copy link

jo-so-nx commented Oct 5, 2023

Another option is the sysctl knob ip_nonlocal_bind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants