From bc06e9ac6050be3494d4ec8643ab16aa937dc82d Mon Sep 17 00:00:00 2001 From: Gwendal Raoul Date: Tue, 18 Jun 2019 15:22:41 +0200 Subject: [PATCH] Transport: stop service if mqtt connection cannot be established --- python_transport/wirepas_gateway/protocol/mqtt_wrapper.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python_transport/wirepas_gateway/protocol/mqtt_wrapper.py b/python_transport/wirepas_gateway/protocol/mqtt_wrapper.py index 79d3f372..29b535f7 100644 --- a/python_transport/wirepas_gateway/protocol/mqtt_wrapper.py +++ b/python_transport/wirepas_gateway/protocol/mqtt_wrapper.py @@ -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): @@ -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: