thingsboard-gateway icon indicating copy to clipboard operation
thingsboard-gateway copied to clipboard

[BUG] OPCUA long back-off time when connection is lost

Open wilterdinkrobert opened this issue 6 months ago • 1 comments

Describe the bug The OPCUA connector waits a very long time before attempting the next connection attempt. This happens already after the first disconnect, which might be due to intermittent wifi/ethernet issues... In an IoT setting I would expect either a exponential back-off with a max of 1 minute or simply trying every 5 seconds (given that the number of devices is limited anyhow).

Connector name (If bug in the some connector): OPC-UA Connector

Error traceback (If available):

2025-06-18 08:26:54 - |INFO| - [opcua_connector.py] - opcua_connector - _load_devices_nodes - 725 - Loading nodes for device: Inspection_Table, section: timeseries, nodes count: 85
2025-06-18 08:26:59 - |WARNING| - [opcua_connector.py] - opcua_connector - start_client - 370 - Connection lost for OPC-UA Connector 1, will try to reconnect...
2025-06-18 08:27:00 - |INFO| - [opcua_connector.py] - opcua_connector - retry_connect_with_backoff - 410 - Last contact was 7.02 seconds ago, next connection try in 112.98 seconds...
2025-06-18 08:27:04 - |WARNING| - [opcua_connector.py] - opcua_connector - start_client - 370 - Connection lost for OPC-UA Connector 2, will try to reconnect...
2025-06-18 08:27:04 - |WARNING| - [opcua_connector.py] - opcua_connector - start_client - 370 - Connection lost for OPC-UA Connector 3, will try to reconnect...
2025-06-18 08:27:05 - |INFO| - [opcua_connector.py] - opcua_connector - retry_connect_with_backoff - 410 - Last contact was 10.72 seconds ago, next connection try in 109.28 seconds...
2025-06-18 08:27:05 - |INFO| - [opcua_connector.py] - opcua_connector - retry_connect_with_backoff - 410 - Last contact was 9.95 seconds ago, next connection try in 110.05 seconds...

Versions (please complete the following information):

  • OS: Ubuntu
  • Thingsboard IoT Gateway version: Docker 3.7.4

wilterdinkrobert avatar Jun 18 '25 08:06 wilterdinkrobert

Hi @wilterdinkrobert,

Thank you for your interest in ThingsBoard IoT Gateway,

We have added a new parameters to OPC-UA connector (reconnectRetriesCount default 8, reconnectBackoffInitialDelay default 1, reconnectBackoffFactor default 2), these parameters allow to control reconnect behavior. You will need to change reconnectRetriesCount it changes amount of retries and the total time. Or you will be able to change reconnectBackoffInitialDelay to 5 and reconnectBackoffFactor to 1 - this configuration changes behavior to try each 5 seconds. These configuration parameters will be available in the next release. They are expected to be on the same level with url configuration (in server section).

imbeacon avatar Jun 18 '25 09:06 imbeacon

Thank you for the quick addition to the code. Will certainly configure this when the new release comes out!

wilterdinkrobert avatar Jun 20 '25 07:06 wilterdinkrobert