I cannot connect to my mosquitto container from the local network. I’m able to sub or pub to my MQTT broker from within the docker container but cannot connect from other machines on the local network. I have adjusted the security settings for mosquito 2.x. My mosquito.config file looks like this:
listener 1883
allow_anonymous true
My docker _compose file looks like this (the html formatting is stripping the indents):
version: ‘3.8’
services:
mqtt:
image: eclipse-mosquitto
container_name: mosquitto-container
restart: always
ports:
- “1883:1883”
- “9001:9001”
- “8883:8883”
volumes:
- /volume1/Docker/IOT/Mosquitto/config:/mosquitto/config
- /volume1/Docker/IOT/Mosquitto/data:/mosquitto/data
- /volume1/Docker/IOT/Mosquitto/log:/mosquitto/log
Should I add the IP address of the server (192.168.2.102) to the “listener” line in the conf file? I have not seen this in any examples. The examples all just show the port number (1883).
When I sudo docker exec -it mosquitto-container /bin/ash to open a shell in the container, I can successfully issue mosquitto_sub and mosquitto_pub commands. If I modify the config file and create a passwords file, I can successfully issue authenticated pub and sub commands with the appropriate -u and -P options but only from within the docker instance. If I try from other devices (an IOT device or a different machine running MQTT Explorer), they just do not connect.
Other docker containers (Home Assistant and Rcon) work fine on the local network. When testing with MQTT Explorer, there is a long delay before a timeout when I try to connect to the correct port (1883) but an instant fail when try to connect to wrong port (1890). I assume this means something is trying to happen as the connections is not immediately refused.
I’m a bit over my head and I really do not know how to trouble shoot from here. Any help very much appreciated.
My Docker session is running on an Asustor AS5304T NAS (Busybox) and I am administering via Portainer with SSH access for pub/sub commands and config file editing.