import paho.mqtt.client as mqtt def on_message(client, userdata, msg): print 'Received: ' + msg.payload client = mqtt.Client() client.on_message = on_message client.connect('localhost', 1883) client.subscribe('hello/#') client.loop_forever()
import paho.mqtt.client as mqtt client = mqtt.Client() client.will_set('hello/will', 'Last will', 0, False) client.connect('localhost', 1883) client.publish('hello/world', 'Regular msg', 0, False) client.disconnect()
Received: Last will