In [14]:
import paho.mqtt.client as mqtt

In [15]:
def on_connect(client, userdata, flags, rc):
    print("Connected with result code "+str(rc))

    # Subscribing in on_connect() means that if we lose the connection and
    # reconnect then subscriptions will be renewed.
    client.subscribe("jun-intel-edison/temperature")

In [16]:
def on_message(client, userdata, msg):
    print(msg.topic+" "+str(msg.payload))

In [17]:
client=mqtt.Client()

In [18]:
client.on_connect=on_connect

In [19]:
client.on_message=on_message

In [ ]:
client.connect("test.mosquitto.org")


Out[ ]:
0

In [ ]:
client.loop_forever()


Connected with result code 0
jun-intel-edison/temperature b'what a hell'
jun-intel-edison/temperature b'what a hell'
jun-intel-edison/temperature b'what a hell'
jun-intel-edison/temperature b'what a hell'
jun-intel-edison/temperature b'what a hell'

In [ ]: