This is a demostration of MQTT protocol. To give a brief illustration, this README is only about Python version demo. Other language version are the same as Python's version.
For Java version you can visit this project.
For JavaScript version, please checkout npm project.
For Scala version, please checkout here.
-
MQTT broker: Mosquitto (yap, an additional 't' there)
- Ubuntu:
sudo apt-get install mosquitto
- OS X:
brew install mosquitto
- Ubuntu:
-
The Mosquitto Python Module
pip install paho-mqtt
- For Java, Scala version, you should download Java libraries org.eclipse.paho.client.mqttv3 and org.eclipse.paho.mqtt.utility
-
You should first launch an MQTT broker server. With instanlling mosquitto, you can launch a server with purely type
mosquitto
. -
Then use
python mqtt_subscriber.py
andpython mqtt_publisher.py
respectively.
The publisher will automatically terminate after send a message to broker. To terminate subscriber and broker server, use ctrl + C
or control + C
for times.