Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes for Socket and REST connectors #1273

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion thingsboard_gateway/connectors/rest/rest_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def __run_server(self):

self.load_handlers()
web.run_app(self._app, host=self.__config['host'], port=int(self.__config.get('port', 5000)),
handle_signals=False, ssl_context=ssl_context, reuse_port=True, reuse_address=self.__config['host'],
handle_signals=False, ssl_context=ssl_context, reuse_port=True, reuse_address=True,
access_log=self.__log)

def run(self):
Expand Down
4 changes: 3 additions & 1 deletion thingsboard_gateway/connectors/socket/socket_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(self, gateway, config, connector_type):
self.__socket_port = config['port']
self.__socket_buff_size = config['bufferSize']
self.__socket = socket.socket(socket.AF_INET, SOCKET_TYPE[self.__socket_type])
self.__socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.__converting_requests = Queue(-1)

self.__devices, self.__device_converters = self.__convert_devices_list()
Expand Down Expand Up @@ -293,8 +294,9 @@ def __attribute_request_callback(self, response, _):
def close(self):
self.__stopped = True
self._connected = False
self.__connections = {}
self.__socket.close()
self.__connections = {}
self.__log.info('%s connector has been stopped.', self.get_name())
self.__log.reset()

def get_name(self):
Expand Down
Loading