Search code examples
windowsdockermqttmosquitto

How to test mqtt on docker in windows?


I have pulled the eclipse-mosquitto image on the docker. How can I test the mqtt client by subscribing and publishing some message through docker?

Following are the details of my system:

Operating System: Windows 10 Home

Docker version 19.03.1

Can someone please guide me with the steps on how to test the mqtt on docker in windows 10?

Thank you


Solution

  • You can test using MQTT client docker container.

    • server

    Start eclipse-mosquitto container

    docker run --name mq -it -p 1883:1883 -p 9001:9001  eclipse-mosquitto
    
    
    • client:

    Then open another terminal window and run subscriber command using docker MQTT client

    docker run --rm -it   --link mq   ruimarinho/mosquitto mosquitto_sub -h mq -t '#'
    
    

    Now open another terminal window and publish a message, you will able to see message in window 2.

    docker run --rm -it   --link mq   ruimarinho/mosquitto mosquitto_pub -h mq -t home-assistant/switch/1/on -m "Docker pub-subtest message"
    
    

    enter image description here