How To Install and Use Mosquitto For Windows
How To Install and Use Mosquitto For Windows
How To Install and Use Mosquitto For Windows
Windows
Introduction
Mosquitto is an application for the MQTT protocol. It can be used as a broker, subscriber
and publisher.
This guide will covers how to use Mosquitto as an application, not as a Windows service.
Installation
Download Mosquitto from https://mosquitto.org/download/ and install it.
If you install it with the “Service” checkbox checked, it will start automatically with Windows
and occupy the default port 1883.
If you installed Mosquitto this way you can disable the service by going into the Services
menu in Windows and pressing the stop button with the Mosquitto Broker selected.
When a subscriber subscribes to your broker, it will look something like this.
This subscriber is now subscribed to the topic testTopic on the broker running on the local
IP on port 1883.
To subscribe to another IP and/or another port use -h *IP here* -p *port here* as additional
arguments when starting mosquitto_sub.exe
This publisher has just sent a message to the broker on my local computer, on port 1883, on
topic testTopic with the message Test message.
To publish to another IP and/or another port use -h *IP here* -p *port here* as additional
arguments when starting mosquitto_pub.exe
This publisher just sent the same as above, although this time with debug messages
enabled.
Broker, sub and pub all working together
A printscreen of all 3 different programs running one one computer. The broker in the top
right, subscriber in top left and publisher in bottom left.
Troubleshooting
If you get an error telling you that “normally only one user is allowed per socketaddress
(procol/network address/port)” you might have another application already running, listening
on port 1883. Check if you already have another cmd window with a broker running on the
same port. Alternatively a Mosquitto broker might be running already as a service. Scroll up
to the installation section of this guide to see how to fix this.