Installing a Mosquitto broker on Windows
Follow these steps to install a Mosquitto broker on Windows. Take into account that you will require Windows Vista or higher (Windows 7, 8, 8.1, 10 or greater).
- Download the executable file listed under Binary Installation and Windows that provides the native build in the Mosquitto downloads web page:
http://mosquitto.org/download
. For Moquitto 1.4.10, the file name is
mosquito-1.4.10-install-win32.exe
. You must click or tap on the file name and you will be redirected to the Eclipse repository with many mirror options, including a default recommendation, from which you can download the executable file. - Run the previously downloaded executable file and the Mosquitto Setup Wizard will display its Welcome dialog box. Click Next > to continue. The setup wizard will display the dependencies that you must install: OpenSSL and pthreads. The dialog box will display the links that you can use to download and run installers for these two requirements.
- If you don't have Win32 OpenSSL v1.0.2j Light installed on Windows, go to the Win32 OpenSSL web page:
http://slproweb.com/products/Win32OpenSSL.html
and download the Win32 OpenSSL v1.0.2k Light file listed in a table under Download Win32 OpenSSL. Do not download the Win64 version because you will need the Win32 version to make it possible for Mosquitto to have its dependencies. If you already have Win32 OpenSSL v1.0.2k Light installed, advance to step number 7. For Win32 OpenSSL v1.0.2k Light, the file name is
Win32OpenSSL_Light-1_0_2j.exe
. Run the downloaded executable file and OpenSSL Light (32-bit) will display its Welcome dialog box. Click Next > to continue. - The setup wizard will display the License Agreement. Read it, select I Accept the agreement and click Next >. Select the folder in which you want to install OpenSSL Light (32-bit) in case you don't want to use the default folder. Remember the folder you specify because you will need to copy a few DLL files from this folder later. The default folder is
C:OpenSSL-Win32
. - Click Next > to continue, specify a different Start Menu folder if necessary and click Next >. Select The OpenSSL binaries (/bin) directory as the desired option to Copy OpenSSL DLLs to. This way, the installation will copy the DLLs to a
bin
sub-folder within the previously specified folder, by default,C:OpenSSL-Win32bin
. - Click Next > to continue. Review the selected installation options and click Install to complete the installation for OpenSSL Light (32-bit). Finally, consider a donation to the Win32 OpenSSL project and click Finish to exit setup.
- Go to the following address in your web browser:
ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/dll/x86
. The browser will display many files for this FTP directory. Right click on pthreadVC2.dll and save the file in your
Downloads
folder. You will have to copy this DLL to the Mosquitto installation folder later. - Now, go back to the Mosquitto Setup window and click Next > to continue. By default, Mosquitto will install the files and the Mosquitto Service. Use the default components installation options and click Next > to continue.
- Select the folder in which you want to install Mosquitto in case you don't want to use the default folder. Remember the folder you specify because you will need to copy a few DLL files to this folder later. The default folder is
C:Program Files (x86)mosquitto
. Click Install to complete the installation. Once the installation has completed click Finish to close the Mosquitto Setup Wizard. - Open a File Explorer window and go to the
bin
sub-folder within the folder in which you installed OpenSSL Light (32-bit), by default,C:OpenSSL-Win32bin
. - Copy the following two DLLs:
libeay32.dll
andssleay32.dll
. Now, go to the folder in which you installed Mosquitto and paste these two DLLs. By default, the Mosquitto installation folder isC:Program Files (x86)mosquitto
. You will need to provide administrator permission to paste the DLLs in the default folder. - Open a File Explorer window and go to your
Downloads
folder. Copy the pthreads DLL you downloaded in one of the previous steps:pthreadVC2.dll
. Now, go to the folder in which you installed Mosquitto and paste this DLL. You will need to provide administrator permission to paste the DLL in the default Mosquitto installation folder. - Now that all the dependencies are included in the Mosquitto installation folder, it is necessary to run the installation again to make the Mosquitto Setup configure the Windows service. Run the previously downloaded Mosquitto installation executable again. For Moquitto 1.4.10, the file name is
mosquito-1.4.10-install-win32.exe
. Make sure you specify the same installation folder as the folder in which you copied the DLLs and that theService
component is activated. Click Next > many times and click Install to complete the configuration for the Windows service. Once the installation has completed click Finish to close the Mosquitto Setup Wizard. - Open the Services application in Windows and search for the service whose name is Mosquitto Broker. Right click on the service name and select Start. The Status will change to Running. By default, the service is configured to have its Startup Type set to Automatic. If you don't want to automatically start the Mosquitto Broker service, change the Startup Type to Manual. You will have to repeat the step you just did to manually start the service before working with Mosquitto on the Windows computer.
Open a Command Prompt window and run the following command to check whether the Mosquitto MQTT server is listening at the default port: 1883.
netstat -an | findstr 1883
The following lines show the results of the previous command that indicate the Mosquitto MQTT server has opened an IPv4 and an IPv6 listen socket on port 1883:
TCP 0.0.0.0:1883 0.0.0.0:0 LISTENING TCP [::]:1883 [::]:0 LISTENING