Session automatically Reconnected but subscription is not

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

Moderator: uasdkc

Post Reply
lthanga
Jr. Member
Jr. Member
Posts: 2
Joined: 28 Oct 2018, 08:00

Session automatically Reconnected but subscription is not

Post by lthanga »

Hi

I am having issues with the client disconnecting and reconnecting, where it has already:
connected with a session
subscribed
and items registered for monitoring.

On disconnecting and reconnecting, the session is recreated, but the subscription is not
In order to continue:
I have to subscribe again (UaClient_Subscription_BeginCreateMonitoredItems) where it complains the subscription id is invalid (0x80280000)
Then delete the monitored items, which again complains of invalid subscription id
Finally register the monitored items (using UaClient_Subscription_BeginCreateMonitoredItems) to continue

what is the correct way of reviving the subscription and the monitored items.

Much appreciated

Thanks
Laguna

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

Re: Session automatically Reconnected but subscription is no

Post by Support Team »

Hello Laguna,

after disconnecting and reconnecting a session, the AnsiC Client SDK does not automatically recreate subscriptions and monitored items. When disconnecting, you should set the DeleteSubscriptions parameter of UaClient_Session_BeginDisconnect to OpcUa_True, in order to clear any subscriptions associated with the session. After connecting again, you'll need to recreate all subscriptions and monitored items you need.
Best regards
Unified Automation Support Team

lthanga
Jr. Member
Jr. Member
Posts: 2
Joined: 28 Oct 2018, 08:00

Re: Session automatically Reconnected but subscription is no

Post by lthanga »

Thank you for the quick reply.

I forgot to mention, that the connection loss is due to server restart/reset (not under client control).
I have set the client to automatically reconnect, which is good so far, it connects and also recreates the session.

But the subscription is not there, and the monitored items are attached to the previous subscription.

How can I, reestablish the subscription and the monitored items, with the new session, and clean up the previous subscription, if needed?

Thanks
Laguna

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

Re: Session automatically Reconnected but subscription is no

Post by Support Team »

Hello Laguna,

you need to keep track on your subscriptions and their monitored items in order to be able to recreate them if they don't exist anymore. For subscriptions that time out or don't exist anymore due to the session being recreated, you'll receive a status changed callback (pfStatusChanged_CB on the UaClient_Subscription_Callback) with a bad status. If this happens, you'll need to recreate the subscription and its monitored items.
Best regards
Unified Automation Support Team

Post Reply