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 
https://systemd.io/NETWORK_ONLINE/
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.

So I would suggest the attached patch without beeing sure about that.

Unfortunately the bug is also no longer reproducible on my systems. So
I can't verify the patch is working.

--- a/service/systemd/mosquitto.service.notify
+++ b/service/systemd/mosquitto.service.notify
@@ -1,8 +1,8 @@
 [Unit]
 Description=Mosquitto MQTT Broker
 Documentation=man:mosquitto.conf(5) man:mosquitto(8)
-After=network.target
-Wants=network.target
+After=network-online.target
+Wants=network-online.target
 
 [Service]
 Type=notify
--- a/service/systemd/mosquitto.service.simple
+++ b/service/systemd/mosquitto.service.simple
@@ -1,8 +1,8 @@
 [Unit]
 Description=Mosquitto MQTT Broker
 Documentation=man:mosquitto.conf(5) man:mosquitto(8)
-After=network.target
-Wants=network.target
+After=network-online.target
+Wants=network-online.target
 
 [Service]
 ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Reply via email to