The Mosquitto or MQTT broker is an OASIS standard messaging protocol for IoT. The inculcation of IoT in modern-day lives has pulled MQTT in the picture. Being a lightweight messaging transport that can remotely connect devices, MQTT tutorials were in much demand. So, here we portray one tutorial for the installation of Mosquitto MQTT broker Windows.
There exist three different ways of installing Mosquitto broker on Windows.
- Standard install
- Quick install
- Windows PowerShell install
We will first see the basic one, i.e., the Standard Install. And then move on to the Quick and PowerShell installation methods.
Method 1: Standard or Manual Installation of MQTT Broker on Windows
When obeying this standard procedure, you will have to install certain other dependencies.
To start with the manual installation procedure, the pre-requisite is to download files from Eclipse as a part of the dependencies.
Mosquitto can be downloaded as a service since version 15.8. In this case, Mosquitto starts automatically.
But before these, you need to install the Windows installation files.
So now, let’s move on to the installation steps.
1: Double click on install script.
2: The “Dependencies” screen will appear, which will tell you about the required additional files.
3: In the “Choose Components” page, tick the box that will install Mosquitto as a “Service.”
4: By default, the location of installation will be set at C:\ program files\mosquitto. If you want to install the service somewhere else, you can browse to that particular location.
5: Click on “Finish” to complete the process.
After the above steps get executed successfully, you now need to copy the additional files to the install directory.
Two additional files will be available for copying, as listed below:
- libcrypto-1_1_x64.dll
- libssl-1_1_x64.dll
Point to Note: These files are included in the 1.5.8 install package. And you can also get these files by installing OpenSSL.
Starting MQTT on Your Windows Device
For manual starting of the MQTT broker, open “Command Window.” Navigate to the directory where you installed Mosquitto and type mosquitto.
If saved in C drive, the command will appear as: C:\mosquitto>mosquitto
If you want to use command-line switches, type
mosquitto -h
It will open the “Help” section for you, as shown in the below-given snapshot.
The command mosquitto -v will let you start in verbose mode, and you can thus see the console messages.
Method 2: Quick Installation of MQTT Broker Windows
Many people don’t prefer the traditional manual way of installing an MQTT broker. It is because the manual process involves the installation of many other dependencies. To avoid the hectic process of copying files from here to there and finding sources to download the dependencies, many users have shifted to the Quick install process.
The mosquitto version 1.5.8 works well with WebSockets.
While Quick installation, you can take the help of online sites that offer quick links for downloading all the packages at one go. Then, you can unzip the folders in the directory where you have kept MQTT. Henceforth, follow the steps as discussed for standard installation.
Method 3: MQTT Installation via PowerShell
It is an alternative installation process involving Windows PowerShell.
1: Open the PowerShell Command prompt by selecting “Run as Administrator” option.
2: Chose the directory where you want to install mosquitto and type the below command:
./mosquitto install
3: Mosquitto will get installed, but you won’t get any notification.
4: To start mosquitto, reboot your device, or start it manually.
5: Open the regular command prompt as Administrator and type the following codes. Make sure it is in the same given sequence.
- sc query mosquitto, sc start mosquitto, sc query mosquitto
Testing the Installation
Now that you have done your part of the installation, how can you confirm whether the process got executed successfully?
Well, it is simple.
- Open command window
- Type down the below command
- netstat -a
The format should be as follows:
C:\ Users\ username> netstat -a
Running the command should show you that the MQTT broker is running on port 1883.
So, these were some of the ways to install the Mosquitto MQTT broker Windows. I hope the tutorial will be beneficial for you.