From eb4e71fa692dfd1230383fcdf4f2a96e07b86905 Mon Sep 17 00:00:00 2001 From: zbeacon Date: Thu, 20 Jan 2022 09:05:22 +0200 Subject: [PATCH] Fix for #692 --- thingsboard_gateway/gateway/tb_client.py | 12 ++++++++---- .../tb_utility/tb_gateway_remote_configurator.py | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/thingsboard_gateway/gateway/tb_client.py b/thingsboard_gateway/gateway/tb_client.py index 9dd133a9..b676641f 100644 --- a/thingsboard_gateway/gateway/tb_client.py +++ b/thingsboard_gateway/gateway/tb_client.py @@ -14,7 +14,7 @@ import logging import threading -from time import time, sleep +from time import sleep from ssl import CERT_REQUIRED, PROTOCOL_TLSv1_2 from thingsboard_gateway.tb_client.tb_gateway_mqtt import TBGatewayMqttClient @@ -27,6 +27,7 @@ class TBClient(threading.Thread): super().__init__() self.setName('Connection thread.') self.daemon = True + self.__config_folder_path = config_folder_path self.__config = config self.__host = config["host"] self.__port = config.get("port", 1883) @@ -45,9 +46,9 @@ class TBClient(threading.Thread): self.__token = str(credentials["accessToken"]) self.client = TBGatewayMqttClient(self.__host, self.__port, self.__token, self, quality_of_service=self.__default_quality_of_service) if self.__tls: - self.__ca_cert = config_folder_path + credentials.get("caCert") if credentials.get("caCert") is not None else None - self.__private_key = config_folder_path + credentials.get("privateKey") if credentials.get("privateKey") is not None else None - self.__cert = config_folder_path + credentials.get("cert") if credentials.get("cert") is not None else None + self.__ca_cert = self.__config_folder_path + credentials.get("caCert") if credentials.get("caCert") is not None else None + self.__private_key = self.__config_folder_path + credentials.get("privateKey") if credentials.get("privateKey") is not None else None + self.__cert = self.__config_folder_path + credentials.get("cert") if credentials.get("cert") is not None else None self.client._client.tls_set(ca_certs=self.__ca_cert, certfile=self.__cert, keyfile=self.__private_key, @@ -144,3 +145,6 @@ class TBClient(threading.Thread): self.__stopped = True except Exception as e: log.exception(e) + + def get_config_folder_path(self): + return self.__config_folder_path diff --git a/thingsboard_gateway/tb_utility/tb_gateway_remote_configurator.py b/thingsboard_gateway/tb_utility/tb_gateway_remote_configurator.py index 960f9a62..5c27729d 100644 --- a/thingsboard_gateway/tb_utility/tb_gateway_remote_configurator.py +++ b/thingsboard_gateway/tb_utility/tb_gateway_remote_configurator.py @@ -197,7 +197,7 @@ class RemoteConfigurator: self.__old_tb_client.unsubscribe('*') self.__old_tb_client.stop() self.__old_tb_client.disconnect() - self.__gateway.tb_client = TBClient(self.__new_general_configuration_file["thingsboard"]) + self.__gateway.tb_client = TBClient(self.__new_general_configuration_file["thingsboard"], self.__old_tb_client.get_config_folder_path()) self.__gateway.tb_client.connect() connection_state = False while time() * 1000 - apply_start < self.__apply_timeout * 1000 and not connection_state: