Multithreaded requests to OPC UA Server

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
Full Member
Full Member
Posts: 5
Joined: 11 Feb 2013, 13:35

Multithreaded requests to OPC UA Server

Post by gisTRON »

I have a project with several subdirectories. Each subdirectory contains a machine.
- myProject
+ machine A
+ machine B
+ machine C

Every machine itself has several subdirectories. e.g.

- machine A
-- value1
-- value2

Right now I query everything sequentially.

query machineA(); takes 3 seconds
query machineB(); takes 3 seconds
query machineC(); takes 3 seconds
takes 9 seconds to read all values for all 3 machines. I am not sure why it takes 3 seconds for each subdirectory.

Would the OPC UA Server be able to work with multithreaded requests and provide the data for 3 machines in 3 and not 9 seconds?
Is there any multithreading server-side or is everything done sequentially?

User avatar
Support Team
Hero Member
Hero Member
Posts: 2532
Joined: 18 Mar 2011, 15:09

Re: Multithreaded requests to OPC UA Server

Post by Support Team »

Hi gisTRON!

What are you doing to access when you say ‘query machineA’. Is this a file I/O call using the .NET DirectoryInfo structure? If so performance is very dependent on the system and but 3s does sound large unless it is a recursive browse through a directory structure. In the .NET Server SDK there are two ways to process requests: one by one or as batches. If you use the ‘one by one’ design pattern then the requests are processed sequentially. You control which design pattern you use by the methods you choose to overload.
For example, the Read method signatures are:

Code: Select all

protected virtual DataValue Read(
    RequestContext context,
    NodeAttributeHandle nodeHandle,
    string indexRange,
    QualifiedName dataEncoding)

protected virtual void Read(
    RequestContext context,
    TransactionHandle transaction,
    IList<NodeAttributeOperationHandle> operationHandles,
    IList<ReadValueId> settings)
What you want to do is process requests as a batch by overriding both Read methods. For the synchronous version you must return null which tells the SDK to call the batch version. In the batch version you must hand off control to whatever thread you want to use for the processing. When processing completes you must invoke the callback which is part of the transaction one for each value. e.g:

Code: Select all

    new DataValue() { StatusCode = StatusCodes.BadNodeIdUnknown },
More information is here: ... anOverview

Best Regards,
Support Team

Post Reply