I'm trying to enable websocket on mosquitto 2.0.11 in Ubuntu 22.04.
Here my /etc/mosquitto/mosquitto.conf:
pid_file /run/mosquitto/mosquitto.pid
per_listener_settings true
password_file /etc/mosquitto/pwd_mqtt
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
connection_messages true
log_timestamp true
listener 1883
protocol mqtt
allow_anonymous false
listener 8080
protocol websockets
allow_anonymous false
Starting it with: mosquitto -c /etc/mosquitto/mosquitto.conf -v it outputs in /var/log/mosquitto/mosquitto.log:
1707293771: mosquitto version 2.0.11 starting
1707293771: Config loaded from /etc/mosquitto/mosquitto.conf.
1707293771: Opening ipv4 listen socket on port 1883.
1707293771: Opening ipv6 listen socket on port 1883.
1707293771: Opening websockets listen socket on port 8080.
1707293771: Opening ipv4 listen socket on port 1883.
1707293771: Error: Address already in use
Why does it try to open again port 1883 on the second listener?
I've duplicated this with Mosquitto 2.0.18:
The issue appears to be that
password_fileis aper_listenersetting, but in your config you have it placed above thelistenerlines, meaning that it applies to the default listener. To solve this either removeper_listener_settings true(it's not needed in your config as it stands), or move thepassword_fileline i.e. (simplified things a little):See this issue for something similar.