Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paho.mqtt.client as paho
- import os
- import time
- from random import randint
- import json
- myhash = randint(20000,30000)
- broker = "127.0.0.1"
- port = 1883
- mypid = os.getpid()
- client_uniq = client_uniq = "client123"
- mqttc = paho.Client(client_uniq, True)
- # Connect with timeout
- mqttc.connect(broker, port, 60)
- def on_message( mosq, obj, msg):
- print "what's payload: ", msg.payload
- # Subscribe
- mqttc.subscribe('mqtt-subscription-client123qos1',1)
- mqttc.on_message = on_message
- while mqttc.loop()==0:
- msg = 13
- mqttc.publish("request", msg , qos=1, retain=False) # qos = 0,
- print "Message Published"
- time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement