def connect_with_retry(self):
try:
self.client.connect(self.broker_host, port=self.broker_port, keepalive=60)
self.connect_loop.stop()
except:
log.failure(u'Error connecting to MQTT broker but retrying each {retry_interval} seconds',
retry_interval=self.retry_interval)
return
"""
This is part of the threaded client interface. Call this once to
start a new thread to process network traffic. This provides an
alternative to repeatedly calling loop() yourself.
"""
# TODO: Check whether reconnect works with this interface.
self.client.loop_start()
reactor.addSystemEventTrigger('before', 'shutdown', self.client.loop_stop, True)
# The callback for when the client receives a CONNACK response from the server.
评论列表
文章目录