update
This commit is contained in:
parent
42a53c63fa
commit
a5e3ec951c
3
MQTT.py
3
MQTT.py
|
@ -46,7 +46,8 @@ class MQTT:
|
|||
self.client.on_connect = self.on_connect
|
||||
self.client.on_message = self.on_message
|
||||
# Establish a connection
|
||||
self.client.connect('ceshi-mqtt.lihaink.cn', 1883)
|
||||
# ceshi-mqtt.lihaink.cn
|
||||
self.client.connect('127.0.0.1', 1883)
|
||||
# Publish a message
|
||||
self.client.loop_forever(retry_first_connection=True)
|
||||
|
||||
|
|
2
ceshi.py
2
ceshi.py
|
@ -35,7 +35,7 @@ if __name__ == '__main__':
|
|||
client.on_connect = on_connect
|
||||
client.on_connect_fail = on_connect_fail
|
||||
# Establish a connection
|
||||
client.connect('ceshi-mqtt.lihaink.cn', 1883)
|
||||
client.connect('127.0.0.1', 1883)
|
||||
# Publish a message
|
||||
client.loop_forever()
|
||||
except Exception as e:
|
||||
|
|
|
@ -40,11 +40,12 @@ def on_connect(client, userdata, flags, rc):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
client = mqtt.Client(transport="websockets")
|
||||
client = mqtt.Client()
|
||||
client.username_pw_set("demo", "123456")
|
||||
# Specify callback function
|
||||
client.on_connect = on_connect
|
||||
# Establish a connection
|
||||
client.connect('ceshi-mqtt.lihaink.cn', 8083)
|
||||
# ceshi-mqtt.lihaink.cn
|
||||
client.connect('192.168.1.27', 1883)
|
||||
# Publish a message
|
||||
client.loop_forever()
|
||||
|
|
Loading…
Reference in New Issue