update
This commit is contained in:
parent
ee953c9c73
commit
232a2955cc
8
MQTT.py
8
MQTT.py
|
@ -67,11 +67,6 @@ def on_message(client, userdata, msg):
|
|||
|
||||
times = 120
|
||||
|
||||
|
||||
def exec_shutdown():
|
||||
pass
|
||||
|
||||
|
||||
client = mqtt.Client(client_id=device_name)
|
||||
client.username_pw_set("demo", "123456")
|
||||
# Specify callback function
|
||||
|
@ -81,9 +76,8 @@ while True:
|
|||
try:
|
||||
# ceshi-mqtt.lihaink.cn
|
||||
client.connect('192.168.1.27', 1883)
|
||||
client.loop_forever()
|
||||
client.loop_start()
|
||||
except Exception as e:
|
||||
print("Connection failed:", e)
|
||||
time.sleep(10)
|
||||
print("正在尝试重连")
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ while True:
|
|||
try:
|
||||
# ceshi-mqtt.lihaink.cn
|
||||
client.connect('192.168.1.27', 1883)
|
||||
client.loop_forever()
|
||||
client.loop_start()
|
||||
except Exception as e:
|
||||
print("Connection failed:", e)
|
||||
if times == 0:
|
||||
|
|
Loading…
Reference in New Issue