Skip to content

Commit

Permalink
Transport: stop service if mqtt connection cannot be established
Browse files Browse the repository at this point in the history
  • Loading branch information
GwendalRaoul authored and Pedro Silva committed Jul 8, 2019
1 parent 12fbed5 commit 1c23ac1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion python_transport/wirepas_gateway/protocol/mqtt_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from time import sleep

from paho.mqtt import client as mqtt
from paho.mqtt.client import connack_string


class MQTTWrapper(Thread):
Expand Down Expand Up @@ -69,7 +70,8 @@ def __init__(self, logger, username, password, host, port, secure_auth=True, ca_

def _on_connect(self, client, userdata, flags, rc):
if rc != 0:
self.logger.error("MQTT cannot connect {}".format(rc))
self.logger.error("MQTT cannot connect: {}".format(connack_string(rc)))
self.running = False
return

if self.on_connect_cb is not None:
Expand Down

0 comments on commit 1c23ac1

Please sign in to comment.