thingsboard / thingsboard-gateway

Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
https://thingsboard.io/docs/iot-gateway/what-is-iot-gateway/
Apache License 2.0
1.72k stars 829 forks source link

[BUG] OPCUA it takes 3 minutes for 15 Variables before being ready #698

Closed ysimonx closed 2 years ago

ysimonx commented 2 years ago

Scanning OPCUA path is very long Each time I start thingsboard-gateway, the process scans for UA variables specified in a opcua.json file with a path example { "key": "deltap100", "path": "${User Registers\\.cPURE\\.Fan\\.DeltaP_100}" }

The process is very long before the gateway is ready It takes at least 3 minutes for 15 variables (7 telemetry, 7 attributes, 1 shared attribute) before being able to process MQTT uplink and downlink

OPC-UA Connector:

Versions :

ysimonx commented 2 years ago

reverse-engineering :

def get_node_path(self, node: Node):

        return '\\.'.join(node.get_browse_name().Name for node in node.get_path(200000))

builds a fullpath for each node and is too long

if I add a "LRU Cache" for this function

@lru_cache(maxsize=None)
def get_node_path(self, node: Node):

        return '\\.'.join(node.get_browse_name().Name for node in node.get_path(200000))

Instead of 3 minutes, I have to wait only 30 seconds 6 times faster

ysimonx commented 2 years ago

Same result with


@cachetools.func.ttl_cache(maxsize=1000, ttl=10 * 60)
def get_node_path(self, node: Node):
samson0v commented 2 years ago

Hi @ysimonx, is it ok to close this issue?

ysimonx commented 2 years ago

yes @samson0v :) thank you