Open hegerdes opened 2 years ago
I found out that the issue is related to the docker network mode.
When using Swarm Docker defaults to the ingress mode for port-mappings. This allows to loadbalance the incoming request to multiple instances of the container within the overlay network.
When using this mode mosquito will not accept any connections. Any clients will hang at the TCP ACk Handshake level.
When switching to the host-port mode this issue does not occur!
I'm not sure how this is directly connected to Mosquito but I didn't had any issues with other MQTT brokers when used in Docker.
Similar here:
Tried to connect via a custom web app as docker service based on python dash (dash_mqtt
) via websocket.
It only worked after adding network_mode: host
to the mosquitto image service.
Interestingly,
hivemq/mqtt-cli
image as a docker service is able to connect w/o host network mode (con -h mqtt -p 9000 -ws
)paho-mqtt
) as docker service can access via mqtt protocolall without using host network mode.
The mosquitto.conf
used:
listener 1883
protocol mqtt
allow_anonymous true
listener 9000
protocol websockets
socket_domain ipv4
allow_anonymous true
Excerpt from the docker-compose.yml
:
services:
mqttshell:
image: hivemq/mqtt-cli
mqtt:
image: eclipse-mosquitto:2.0
network_mode: host
#ports:
# - "1883:1883"
# - "9000:9000"
webapp:
# some custom image and custom application using python/pip dash_mqtt
# similar to https://github.com/aegis1980/dash-mqtt/blob/main/usage.py
Hello, how did you solved the issue? I suffer apparently the same. If I connect to localhost exposing ws port it works, nevertheless if I connect to the mosquitto container from inside another container and network, calling the container by its name....its does not work. Only see the problem with ws, mqtt works fine....it is really strange
Hello,
I enconterd a strange issue. Running mosquitto with docker run or docker compose works fine. But as soon as I use docker service I cant establish any connections.
My compose file:
And the conf:
This works and i can create a connection with
mosquitto_<pub|sub> -d -t myTopic -u user -P pw -p 1888 -i 123
But as soon as i convert it to docker service or stack the broker does not accept any connections. The client is stick at TCP level sending CONNECT.
I used the some compose file with docker
stack deploy -c docker-compose.yml test-stack
What can be the source?Also I can confirm #2354 and #2338. No logs are printed at all when started with compose, service or stack. Seems like a tty is expected.