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

[BUG] Issues with multiple instances of OPC-UA connector #993

Closed
TheBergam opened this issue Nov 14, 2022 · 1 comment · Fixed by #996
Closed

[BUG] Issues with multiple instances of OPC-UA connector #993

TheBergam opened this issue Nov 14, 2022 · 1 comment · Fixed by #996
Assignees
Labels

Comments

@TheBergam
Copy link

In my setup, I have the thingsboard gateway connecting to 12 separate OPC-UA servers, monitoring around 150 tags each.
Each OPC-UA server has the same variable names but they will be sent to different thingsboard devices (e.g. OPC-UA server 1 has a temperature tag that will go to thingsboard device temperature01 and OPC-UA server 2 has a temperature tag that will go to thingsboard device temperature02).

I'm using the OPC-UA assyncio connector, and in my tb_gateway.yaml file I had something like this:

connectors:
 -
   name: OPC-UA Connector 01
   type: opcua_asyncio
   configuration: opcua_01.json
 -
   name: OPC-UA Connector 02
   type: opcua_asyncio
   configuration: opcua_02.json
(...)
 -
   name: OPC-UA Connector 12
   type: opcua_asyncio
   configuration: opcua_12.json

With this setup, the different connectors were sending data to the wrong devices.
I arrived to the conclusion that it was because of the following connector class variables:

class OpcUaConnectorAsyncIO(Connector, Thread):
DATA_TO_SEND = Queue(-1)
SUB_DATA_TO_CONVERT = Queue(-1)

Since DATA_TO_SEND and SUB_DATA_TO_CONVERT are defined outside the methods, they are accessible by all instances of class OpcUaConnectorAsyncIO

Instead of each connector having their own queue, they are accessing the same queues, and a given connector is not checking if the element of the queue they are processing is supposed to be processed by them.

The solution I found was to create a different custom opcua connector for each connection (e.g. CustomOpcUaConnector01, CustomOpcUaConnector02 ... CustomOpcUaConnector12) so that each connector would have its own DATA_TO_SEND and SUB_DATA_TO_CONVERT queues.

Is this something that can be fixed in a new release in order to avoid needing to use a custom connector for each opcua server?
Is there a better way to work around this?

Connector name:

  • OPC-UA Connector assyncio

Versions:

  • OS: Debian GNU/Linux 11 (bullseye)
  • Thingsboard IoT Gateway version: 3.1
  • Python version: 3.9.2
@samson0v
Copy link
Contributor

Hi @TheBergam, we will fix it in the nearest future.

@samson0v samson0v linked a pull request Nov 16, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants