In this example we provide example code for TCP, Websocket, TLS, and Websockets protocols to connect to the MQTT Broker. For more documentation on the use of the python paho-mqtt client, see the Python Client - documentation
- It supports Python 3.4+
pip install paho-mqtt
python3 pub_sub_tcp.py
How to use MQTT in Python (Paho) Comparison of Python MQTT clients