Reader small image

You're reading from  Hands-On MQTT Programming with Python

Product typeBook
Published inMay 2018
Reading LevelExpert
PublisherPackt
ISBN-139781789138542
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Gaston C. Hillar
Gaston C. Hillar
author image
Gaston C. Hillar

Gaston C. Hillar is Italian and has been working with computers since he was 8 years old. Gaston has a Bachelor's degree in computer science (graduated with honors) and an MBA. Currently, Gaston is an independent IT consultant and a freelance author who is always looking for new adventures anywhere in the world. He was a senior contributing editor at Dr. Dobb's, and has written more than a hundred articles on software development topics. He has received the prestigious Intel Black Belt Software Developer award eight times. He has written many articles about Java for Oracle Java Magazine. Gaston was also a former Microsoft MVP in technical computing. He lives with his wife, Vanesa, and his two sons, Kevin and Brandon.
Read more about Gaston C. Hillar

Right arrow

Installing a Mosquitto server on macOS

Follow these steps to install a Mosquitto server on macOS, known as OS X prior to macOS Sierra:

  1. If you don't have Homebrew installed, open a Terminal window and run the command indicated on the Homebrew homepage, http://brew.sh, to install this popular package manager for macOS. The following command will do the job. However, it is convenient to check the Homebrew homepage and check all the detailed instructions that are always updated with the newest versions of macOS that become available. If you already have Homebrew installed, move to the next step:
      /usr/bin/ruby -e "$(curl -fsSL      
https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Open a Terminal window and run the following command to request Homebrew to install Mosquitto:
      brew install mosquitto

Notice that in some cases, Homebrew might require additional software to be installed on your computer before you can install Mosquitto. If it is necessary to install additional software, such as Xcode command-line tools, Homebrew will provide you with the necessary instructions.

  1. The following lines show the last messages shown in Terminal that indicate that Homebrew has installed Mosquitto and the instructions to start the MQTT server:
      ==> Installing dependencies for mosquitto: c-ares, openssl,      
libev, libuv, libevent, libwebsockets
==> Installing mosquitto dependency: c-ares
==> Caveats
A CA file has been bootstrapped using certificates from the
SystemRoots
keychain. To add additional certificates (e.g. the certificates
added in the System keychain), place .pem files in
/usr/local/etc/openssl/certs and run
/usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into
/usr/local, because Apple has deprecated use of OpenSSL in favor
of its own TLS and crypto libraries. If you need to have this
software first in your PATH run:
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >>
~/.bash_profile

For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/openssl/lib
CPPFLAGS: -I/usr/local/opt/openssl/include

==> Installing mosquitto
==> Downloading https://homebrew.bintray.com/bottles/mosquitto-
1.4.14_2.el_capit
##################################################
#####################100.0%
==> Pouring mosquitto-1.4.14_2.el_capitan.bottle.tar.gz
==> Caveats
mosquitto has been installed with a default configuration file.
You can make changes to the configuration by editing:
/usr/local/etc/mosquitto/mosquitto.conf

To have launchd start mosquitto now and restart at login:
brew services start mosquitto

Or, if you don't want/need a background service you can just run:
mosquitto -c /usr/local/etc/mosquitto/mosquitto.conf
  1. After the Mosquitto installation has been completed, run the following command in a new Terminal window to launch Mosquitto with the default configuration file. The -c option followed by /usr/local/etc/mosquitto/mosquitto.conf specifies that we want to use this configuration file:
      /usr/local/sbin/mosquitto -c       
/usr/local/etc/mosquitto/mosquitto.conf

The following is the output after you run the previous command:

     1521488973: mosquitto version 1.4.14 (build date 2017-10-22    
16:34:20+0100) starting
1521488973: Config loaded from
/usr/local/etc/mosquitto/mosquitto.conf.
1521488973: Opening ipv4 listen socket on port 1883.
1521488973: Opening ipv6 listen socket on port 1883.

The last lines indicate the Mosquitto MQTT server has opened an IPv4 and an IPv6 listen socket on the default TCP port, 1883. Leave the Terminal window opened, because we need Mosquitto running on the local computer to work with the next examples.

Previous PageNext Page
You have been reading a chapter from
Hands-On MQTT Programming with Python
Published in: May 2018Publisher: PacktISBN-13: 9781789138542
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.
undefined
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

Author (1)

author image
Gaston C. Hillar

Gaston C. Hillar is Italian and has been working with computers since he was 8 years old. Gaston has a Bachelor's degree in computer science (graduated with honors) and an MBA. Currently, Gaston is an independent IT consultant and a freelance author who is always looking for new adventures anywhere in the world. He was a senior contributing editor at Dr. Dobb's, and has written more than a hundred articles on software development topics. He has received the prestigious Intel Black Belt Software Developer award eight times. He has written many articles about Java for Oracle Java Magazine. Gaston was also a former Microsoft MVP in technical computing. He lives with his wife, Vanesa, and his two sons, Kevin and Brandon.
Read more about Gaston C. Hillar