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

The opcua device was collected through the gateway and it was normal for the first few hours. After running for a few hours, the following error occurred

Open ultimate-smile opened this issue 1 year ago • 1 comments

Describe the bug The opcua device was collected through the gateway and it was normal for the first few hours. After running for a few hours, the following error occurred: Traceback (most recent call last): File "/thingsboard_gateway/connectors/opcua_asyncio/opcua_connector.py", line 181, in start_client await self.__scan_device_nodes() File "/thingsboard_gateway/connectors/opcua_asyncio/opcua_connector.py", line 286, in __scan_device_nodes nodes = await self.find_nodes(device['deviceNodePattern']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/thingsboard_gateway/connectors/opcua_asyncio/opcua_connector.py", line 265, in find_nodes return await self.__find_nodes(node_list, current_parent_node, nodes) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/thingsboard_gateway/connectors/opcua_asyncio/opcua_connector.py", line 252, in __find_nodes final.extend(await self.__find_nodes(node_list[1:], current_parent_node=node, nodes=new_nodes)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/thingsboard_gateway/connectors/opcua_asyncio/opcua_connector.py", line 245, in __find_nodes child_node = await node.read_browse_name() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.local/lib/python3.11/site-packages/asyncua/common/node.py", line 94, in read_browse_name result = await self.read_attribute(ua.AttributeIds.BrowseName) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.local/lib/python3.11/site-packages/asyncua/common/node.py", line 342, in read_attribute result = await self.session.read(params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.local/lib/python3.11/site-packages/asyncua/client/ua_client.py", line 404, in read data = await self.protocol.send_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/.local/lib/python3.11/site-packages/asyncua/client/ua_client.py", line 172, in send_request self.check_answer(data, f" in response to {request.class.name}") File "/root/.local/lib/python3.11/site-packages/asyncua/client/ua_client.py", line 181, in check_answer hdr.ServiceResult.check() File "/root/.local/lib/python3.11/site-packages/asyncua/ua/uatypes.py", line 375, in check raise UaStatusCodeError(self.value) asyncua.ua.uaerrors._auto.BadSessionIdInvalid: The session id is not valid.(BadSessionIdInvalid)

Connector name (If bug in the some connector): { "server": { "name": "OPC-UA", "url": "opc.tcp://127.0.0.1:49320", "timeoutInMillis": 1000, "scanPeriodInMillis": 1000, "disableSubscriptions": false, "subCheckPeriodInMillis": 100, "showMap": false, "security": "Basic128Rsa15", "identity": { "type": "anonymous" }, "mapping": [ { "deviceNodePattern": "Root\.Objects\.Objects\.Farm", "deviceNamePattern": "Farm", "attributes": [ { "key": "aeration", "path": "${Aeration}" }, { "key": "crop", "path": "${Crop}" }, { "key": "temperature", "path": "${Temperature}" }, { "key": "outdoor", "path": "${Outdoor}" } ], "timeseries": [ { "key": "aeration", "path": "${Aeration}" }, { "key": "crop", "path": "${Crop}" }, { "key": "temperature", "path": "${Temperature}" }, { "key": "outdoor", "path": "${Outdoor}" } ] }, { "deviceNodePattern": "Root\.Objects\.Objects\.Greenhouse", "deviceNamePattern": "Greenhouse", "attributes": [ { "key": "aeration", "path": "${Aeration}" }, { "key": "crop", "path": "${Crop}" }, { "key": "temperature", "path": "${Temperature}" }, { "key": "outdoor", "path": "${Outdoor}" } ], "timeseries": [ { "key": "aeration", "path": "${Aeration}" }, { "key": "crop", "path": "${Crop}" }, { "key": "temperature", "path": "${Temperature}" }, { "key": "outdoor", "path": "${Outdoor}" } ] }, { "deviceNodePattern": "Root\.Objects\.Objects\.Farmland", "deviceNamePattern": "Farmland", "attributes": [ { "key": "aeration", "path": "${Aeration}" }, { "key": "crop", "path": "${Crop}" }, { "key": "temperature", "path": "${Temperature}" }, { "key": "outdoor", "path": "${Outdoor}" } ], "timeseries": [ { "key": "aeration", "path": "${Aeration}" }, { "key": "crop", "path": "${Crop}" }, { "key": "temperature", "path": "${Temperature}" }, { "key": "outdoor", "path": "${Outdoor}" } ] } ] } } Error traceback (If available):

'deviceName'
Traceback (most recent call last):
  File "<input>", line 2, in <module>
KeyError: 'deviceName'

Versions (please complete the following information):

  • OS: Static hostname: test Icon name: computer-vm Chassis: vm Machine ID: e047a679dd2d45acb9f6c716421a0765 Boot ID: bad6b6d1725d4ec9afdb565a2a2aeec2 Virtualization: vmware Operating System: CentOS Linux 8 (Core) CPE OS Name: cpe:/o:centos:centos:8 Kernel: Linux 4.18.0-147.el8.x86_64 Architecture: x86-64
  • Thingsboard IoT Gateway version [3.5.1]
  • Python version[3.11]

ultimate-smile avatar Jul 02 '24 02:07 ultimate-smile

Hi @ultimate-smile,

Could you try the version from the master branch, we have added handling for this error and reconnection, if it appears.

imbeacon avatar Jul 03 '24 04:07 imbeacon