reset the connection every hour to be more stable
This commit is contained in:
parent
1f61719768
commit
9fcf1b76b5
12
relay.py
12
relay.py
@ -99,6 +99,7 @@ def end():
|
||||
RUN=0
|
||||
|
||||
def main():
|
||||
reset_count=0
|
||||
print("Start Relay Contorl")
|
||||
sys.stdout.flush()
|
||||
client=mqtt_setup()
|
||||
@ -119,6 +120,17 @@ def main():
|
||||
except:
|
||||
print("Failed to reconnect")
|
||||
sys.stdout.flush()
|
||||
elif reset_count>=720:
|
||||
try:
|
||||
client.loop_stop()
|
||||
client.reconnect()
|
||||
client.subscribe(topic_control)
|
||||
client.loop_start()
|
||||
reset_count=0
|
||||
except:
|
||||
print("Couldn't reconnect");
|
||||
sys.stdout.flush()
|
||||
|
||||
gpio.cleanup()
|
||||
exit()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user