The correct behavior of re-establishing connections

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

Moderator: uasdkcpp

Post Reply
q1109820469
Jr. Member
Jr. Member
Posts: 4
Joined: 23 May 2018, 08:13

The correct behavior of re-establishing connections

Post by q1109820469 »

Hi,

I have some question about the correct behavior of re-establishing connections. In my test, I shutdown the OPC UA server to cut the connection between server and client. Then, started the server. I have around 1000 monitoredIDs in a subscription.

1. When re-establishing the connection, should those monitoredIDs will be recreated automatically?
2. If so, it's going to take a lot of time to recreate 1000 monitoredIDs. Should the No.1000 monitoredID captures all data changes during the recreating? There must be some time before recreating the No.1000. I am not sure whether the data change during this time can be captured by the No.1000.
3. According to the Reconnect Sequence in the OPC UA Part 4,
"The Client shall only create a new Session if ActivateSession fails. TransferSubscriptions is used to transfer the Subscription to the new Session. If TransferSubscriptions fails, the Client needs to create a new Subscription."
Does the C++ based OPC UA SDK achieve the function internal?

Thanks!

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

Re: The correct behavior of re-establishing connections

Post by Support Team »

Hello q1109820469,

of course this only works if the server is running all the time and just the connection is interrupted. Whenever a server is restarted all Sessions and Subscriptions are lost.
The automatic reconnect in our SDK creates a new SecureChannel, then tries to call ActivateSession.
If the session is still there the SDK call republish and tries to get the lost Notifications.
If the session is no longer available the SDK does not call transferSubscription. In that case the application gets notified via the UaSubscriptionCallback::subscriptionStatusChanged.
If subscriptionStatusChanged is called with a bad status code the application needs to create the Subscriptions and MonitoredItems again from scratch.
Best regards
Unified Automation Support Team

han_li
Jr. Member
Jr. Member
Posts: 2
Joined: 23 Jun 2017, 11:18

Re: The correct behavior of re-establishing connections

Post by han_li »

Thanks the support team for your response. I'd like to use the UaSubscriptionCallback::subscriptionStatusChanged to know the status and then re-establish the Subscriptions and MonitoredItems.

After establishing the session and subscription, when I stopped the server, the UaSubscriptionCallback::subscriptionStatusChanged was not called. I'm using the SDK 1.5.

Is the callback implemented in the version 1.5? If not, what the earliest version started supporting this callback? Or, if my case can't trigger the function's callback, what's the condition triggering the callback?

Thank you!

han_li
Jr. Member
Jr. Member
Posts: 2
Joined: 23 Jun 2017, 11:18

Re: The correct behavior of re-establishing connections

Post by han_li »

I found virtual void connectionStatusChanged was called back in my case. I can use it now. Thanks!

Post Reply