Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
MQTT Essentials - A Lightweight IoT Protocol

You're reading from  MQTT Essentials - A Lightweight IoT Protocol

Product type Book
Published in Apr 2017
Publisher Packt
ISBN-13 9781787287815
Pages 280 pages
Edition 1st Edition
Languages

Table of Contents (16) Chapters

MQTT Essentials - A Lightweight IoT Protocol
Credits
About the Author
Acknowledgment
About the Reviewer
www.PacktPub.com
Customer Feedback
Dedication
Preface
1. Lightweight Messaging with MQTT 3.1.1 and Mosquitto 2. Securing an MQTT Mosquitto Server 3. Controlling a Drone with Python 4. Interacting with Sensors in Java 5. Controlling Home Automation in JavaScript 6. Interacting with Actuators in Swift Exersise Answers

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).

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. 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.

  10. 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.

  11. Copy the following two DLLs: libeay32.dll and ssleay32.dll. Now, go to the folder in which you installed Mosquitto and paste these two DLLs. By default, the Mosquitto installation folder is C:Program Files (x86)mosquitto. You will need to provide administrator permission to paste the DLLs in the default folder.

  12. 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.

  13. 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 the Service 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.

  14. 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
You have been reading a chapter from
MQTT Essentials - A Lightweight IoT Protocol
Published in: Apr 2017 Publisher: Packt ISBN-13: 9781787287815
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}