diff --git a/MQTT.py b/MQTT.py index 4491986..831abe8 100755 --- a/MQTT.py +++ b/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("正在尝试重连") - diff --git a/data_upload.py b/data_upload.py index 71b421b..eecbd23 100755 --- a/data_upload.py +++ b/data_upload.py @@ -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: