Skip to content

Commit

Permalink
Updated on_disconnect method
Browse files Browse the repository at this point in the history
  • Loading branch information
imbeacon committed Feb 29, 2024
1 parent 9efad73 commit 4cd7a28
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions thingsboard_gateway/gateway/tb_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import random
import string
import threading
import inspect
from os.path import exists
from ssl import CERT_REQUIRED, PROTOCOL_TLSv1_2
from time import sleep, time
Expand Down Expand Up @@ -213,15 +214,18 @@ def _on_connect(self, client, userdata, flags, result_code, *extra_params):
for callback in self.__service_subscription_callbacks:
callback()

def _on_disconnect(self, client, userdata, result_code):
def _on_disconnect(self, client, userdata, result_code, properties=None):
# pylint: disable=protected-access
if self.client._client != client:
self.__logger.info("TB client %s has been disconnected. Current client for connection is: %s", str(client), str(self.client._client))
client.disconnect()
client.loop_stop()
else:
self.__is_connected = False
self.client._on_disconnect(client, userdata, result_code)
if len(inspect.signature(self.client._on_disconnect).parameters) == 4:
self.client._on_disconnect(client, userdata, result_code, properties)
else:
self.client._on_disconnect(client, userdata, result_code)

def stop(self):
# self.disconnect()
Expand Down

0 comments on commit 4cd7a28

Please sign in to comment.