(from : https://simplifiedthinking.co.uk/2015/10/03/install-mqtt-server/ ) | |
Installing Brew | |
The Mosquitto MQTT Server can be easily installed using Homebrew. If it’s not installed on your system already, then a quick visit to the homepage will give you all you need to get going. Homebrew is an OS X Package Manager for installing and updating non-Mac OS X utilities that are more commonly found in other variants of Linux. To install the basic package manager run the following command. | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
Installing Mosquitto MQTT | |
Let’s use our new Homebrew installation to download and install the necessary Mosquitto binaries. This will also download additional libraries required to support secure access via OpenSSL. | |
brew install mosquitto | |
The install script finishes by providing the instructions to start the MQTT server on startup. | |
ln -sfv /usr/local/opt/mosquitto/*.plist ~/Library/LaunchAgents | |
Finally, to save a restart, the server can be started now by running | |
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mosquitto.plist | |
Now you can test the installation and ensure the server is running successfully. Open a new command window and start a listener. | |
mosquitto_sub -t topic/state | |
In another window, send a message to the listener. | |
mosquitto_pub -t topic/state -m "Hello World" | |
Nicely done. | |
Installing the Python Libraries | |
To create the link between Python and MQTT we need to install the Python Eclipse MQTT library. Visit here for the latest downloads and follow the link to download the required version. Specifically, I downloaded these Python Libraries. | |
Once downloaded, unpack the tar file and install the library | |
tar xvf org.eclipse.pho.mqtt.python-1.1.tar | |
cd org.eclipse.pho.mqtt.python-1.1 | |
sudo python setup.py install | |
And that’s it. We’re ready to start sending and receiving MQTT messages around the home. There are a vast number of additional options that can be set up around the MQTT server – security is an obvious choice, Quality of Service, users, etc. I’m keeping it simple for now. | |
This comment has been minimized.
This comment has been minimized.
To initially launch mosquito and also have it restarted afterwards (e.g. on reboot) use the Homebrew supplied support: $ brew services start mosquitto |
This comment has been minimized.
This comment has been minimized.
Thanks @christophevg |
This comment has been minimized.
This comment has been minimized.
I had to run |
This comment has been minimized.
This comment has been minimized.
How do i change the port to 8083? |
This comment has been minimized.
This comment has been minimized.
@ssaenz11 change this line in
|
This comment has been minimized.
This comment has been minimized.
for someone who got error when running brew link
try this:
|
This comment has been minimized.
This comment has been minimized.
nice tutorial i love it and solve my problems on my mac |
This comment has been minimized.
This comment has been minimized.
I opted to have mine run on startup without a user logging in. To do so, I did:
Then change the user in the mosquitto config file:
(look for line that has |
This comment has been minimized.
This comment has been minimized.
So far this does not work on my system. The broker is running on my Mac, and I can subscribe from one terminal window and publish to it from another if I use "localhost" as the hostname. But if I use the real hostname as assigned by the OS or the IP address assigned by the router, I get "connection refused" from the second terminal window. I also get that error from any other machine, athough it's on the local network. However, from that other machine I can ping the broker Mac using its OS-given hostname. But publish attempts get "connection refused." I even tried running Mosquitto as root. No change. |
This comment has been minimized.
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mosquitto.plist
/usr/local/Cellar/mosquitto/1.4.11_2/homebrew.mxcl.mosquitto.plist: Operation not permitted
Please write a working script in case you wish to expose a gist as public.