From 6c4492b2809357157150e76462876fabb97a5827 Mon Sep 17 00:00:00 2001 From: zbeacon Date: Fri, 10 Apr 2020 12:38:35 +0300 Subject: [PATCH] Fix for auto reconnect #284 --- thingsboard_gateway/gateway/tb_client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/thingsboard_gateway/gateway/tb_client.py b/thingsboard_gateway/gateway/tb_client.py index 8f73a256..740886b9 100644 --- a/thingsboard_gateway/gateway/tb_client.py +++ b/thingsboard_gateway/gateway/tb_client.py @@ -31,7 +31,7 @@ class TBClient(threading.Thread): self.__host = config["host"] self.__port = config.get("port", 1883) credentials = config["security"] - self.__min_reconnect_delay = 10 + self.__min_reconnect_delay = 1 self.__tls = bool(credentials.get('tls', False) or credentials.get('caCert', False)) self.__ca_cert = None self.__private_key = None @@ -79,11 +79,11 @@ class TBClient(threading.Thread): def _on_disconnect(self, client, userdata, result_code): # pylint: disable=protected-access - log.info("TB client %s has been disconnected. Current client for connection is: %s", str(client), str(self.client._client)) if self.client._client != client: + log.info("TB client %s has been disconnected. Current client for connection is: %s", str(client), str(self.client._client)) client.disconnect() - self.__is_connected = False - client.loop_stop() + self.__is_connected = False + client.loop_stop() self.client._on_disconnect(client, userdata, result_code) def stop(self):