eclipse / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
8.61k stars 2.33k forks source link

'socket_domain ipv4' breaks config (listen twice -> Address already in use) #3072

Open antoine-sac opened 1 week ago

antoine-sac commented 1 week ago

I have been troubleshooting a bug preventing mosquitto from booting because it attempts to listen twice to the same port. I finally tracked it down to the socket_domain option.

Here is the simplest reproducible example which fails to start.

cat /etc/mosquitto/test.conf

listener 1885 localhost
socket_domain ipv4

mosquitto -c /etc/mosquitto/test.conf -v

1719099713: mosquitto version 2.0.18 starting
1719099713: Config loaded from /etc/mosquitto/test.conf.
1719099713: Opening ipv4 listen socket on port 1885.
1719099713: Opening ipv4 listen socket on port 1885.
1719099713: Error: Address already in use

And no, I definitely do NOT have another instance running. I can reproduce the issue on any random port.

1719100410: mosquitto version 2.0.18 starting
1719100410: Config loaded from /etc/mosquitto/test.conf.
1719100410: Opening ipv4 listen socket on port 12345.
1719100410: Opening ipv4 listen socket on port 12345.
1719100410: Error: Address already in use

If I remove the "socket_domain" option, I get the expected behaviour:

mosquitto -c /etc/mosquitto/test.conf -v
1719100163: mosquitto version 2.0.18 starting
1719100163: Config loaded from /etc/mosquitto/test.conf.
1719100163: Opening ipv6 listen socket on port 1885.
1719100163: Opening ipv4 listen socket on port 1885.
1719100163: mosquitto version 2.0.18 running