Risk to switch UA Stack to multithread mode

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

Moderator: uasdkc

Post Reply
dingy
Sr. Member
Sr. Member
Posts: 14
Joined: 28 May 2013, 03:15

Risk to switch UA Stack to multithread mode

Post by dingy »

Hello, support team:

Currently, I'm implementing an UA server/client based gateway program in which the UA Client(UA Stack ClientProxy API) is to communicate with its redundant server.

Because a synchronous UA Client is easier to use, so I switch on the macro OPCUA_MULTITHREADED and OPCUA_USE_SYNCHRONISATION in UA Stack .

As the UA Stack that the UA Server SDK depends on is switched to multithread mode, I want to confirm if there will be some impact on the UA Server SDK?

Thanks a lot

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

Re: Risk to switch UA Stack to multithread mode

Post by Support Team »

Hello,

the ANSI C OPC UA SDK is implemented only for single threaded use.

Best regards
Support Team

dingy
Sr. Member
Sr. Member
Posts: 14
Joined: 28 May 2013, 03:15

Re: Risk to switch UA Stack to multithread mode

Post by dingy »

Hello,

If I can not switch on the macro OPCUA_MULTITHREADED, the client API used for the redundancy monitoring will also be on single thread mode. In this case, all of the client request(channel connection, createSession in clientProxy) will be sent asynchronously without any feedback.

For example, when I call OpcUa_Channel_BeginConnect(..., OpcUa_Channel_PfnConnectionStateChanged* pfCallback) associated with a callback function, an OpcUa_GoodCompletesAsynchronously status code is returned, and the callback is never called.

The asynchronous communication without callback is not reliable, but an UA Server/Client is really necessary in some use case(such as redundancy). So, I wonder how can this kind of problem be solved? Do you have some suggestion.

Thanks a lot

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

Re: Risk to switch UA Stack to multithread mode

Post by Support Team »

Hello,

you might want to have a look at the file uaserver_discovery.c, it contains code that is doing exactly what you want to do (asynchronously creating channels, calling UA services). For the asynchronous methods to be processed it is important to continue calling UaServer_DoCom() after issuing the Begin... call.

If you still run into problems, please contact support@unifiedautomation.com for further help.

Best regards,
Unified Automation Support Team

dingy
Sr. Member
Sr. Member
Posts: 14
Joined: 28 May 2013, 03:15

Re: Risk to switch UA Stack to multithread mode

Post by dingy »

Hello,

I found what I want in UaServer_Discover.c.

Thanks a lot

Post Reply