I have been using mosquitto /mqttx/mqtt-explorer for years without issue on several RaspberryPi 5’s (RPi).
A device failed and the backups, so I am creating a fresh install using docker and Latest RPi OS (Bookworm). All applications are installed using compose files.
Mosquitto runs and the logs show no errors:
1763311480: mosquitto version 2.0.22 starting
1763311480: Config loaded from /mosquitto/config/mosquitto.conf.
1763311480: Starting in local only mode. Connections will only be possible from clients running on this machine.
1763311480: Create a configuration file which defines a listener to allow remote access.
1763311480: For more details see
1763311480: Opening ipv4 listen socket on port 1883.
1763311480: Opening ipv6 listen socket on port 1883.
1763311480: mosquitto version 2.0.22 running
The compose file is:
#mosquitto: compose.yaml
services:
mosquitto:
container_name: mosquitto
image: eclipse-mosquitto:latest
hostname: mosquitto
restart: unless-stopped
ports:
- “1883:1883”
- “9001:9001”
environment:
- TZ=Europe/London
networks:
- pi_net
volumes:
# /path/on/host:/path/in/container
- ../../volumes/mosquitto/config/mosquitto.conf:/mosquitto/mosquitto.conf
- ../../volumes/mosquitto/data:/mosquitto/data
- ../../volumes/mosquitto/log:/mosquitto/log
networks:
pi_net:
external: true
… and the config file is:
# mosquitto.conf: Basic listener configuration
listener 1883
protocol mqtt
allow_anonymous true
#WebSocket listener
listener 9001
protocol websockets
allow_anonymous true
#Persistence
persistence true
persistence_location /mosquitto/data/
#Logging
log_dest file /mosquitto/log/mosquitto.log
log_type error
log_type warning
log_type notice
log_type information
I can check mqtt messages are sent/received using two pub/sub terminal windows & exec into the container:
docker exec -it mosquitto sh
terminal 1: mosquitto_sub -t “test”
terminal 2: mosquitto_pub -t “test” -m “Hello World…”
terminal 1 successful receives the test message. Conclusion: everything OK
Next test:
docker ps: (shows published ports:)
5d25fb638d15 eclipse-mosquitto:latest “/docker-entrypoint.…” About a minute ago Up About a minute 0.0.0.0:1883->1883/tcp, [::]:1883->1883/tcp, 0.0.0.0:9001->9001/tcp, [::]:9001->9001/tcp mosquitto
Yup, 1833 and 9001 are published. Conclusion: everything OK.
Next test: network ports:
sudo netstat -tlnp (abbreviated)
tcp 0 0 0.0.0.0:1883 0.0.0.0:* LISTEN 4969/docker-proxy
tcp 0 0 0.0.0.0:9001 0.0.0.0:* LISTEN 4983/docker-proxy
tcp6 0 0 :::1883 :::* LISTEN 4976/docker-proxy
tcp6 0 0 :::9001 :::* LISTEN 4990/docker-proxy
All looks good to me on both ipv4 and ipv6.
Conclusion: mosquitto IS working fine.
But when I come to use:
- mqttx
- mqtt-explorer
- node-red
I cannot establish any connection at all either via mqtt or ws protocols.
Conclusion: mosquitto is fine and all the other three are faulty in some way.
But I just don’t see how.
What other tests can I run to resolve this? All suggestions most gratefully received.
Ric