Subscription Lifetime and MaxKeepAliveTime in OPC UA

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

Moderator: uasdknet

Post Reply
mrahman252003
Sr. Member
Sr. Member
Posts: 13
Joined: 18 Feb 2016, 21:47

Subscription Lifetime and MaxKeepAliveTime in OPC UA

Post by mrahman252003 »

I see 2 properties in Subscription in OPC UA implementation. I see the following code but not sure why those are used? Can anybody explained me?
m_Subscription.Lifetime = 10000;
m_Subscription.MaxKeepAliveTime = 10000;

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

Re: Subscription Lifetime and MaxKeepAliveTime in OPC UA

Post by Support Team »

Best regards
Unified Automation Support Team

mrahman252003
Sr. Member
Sr. Member
Posts: 13
Joined: 18 Feb 2016, 21:47

Re: Subscription Lifetime and MaxKeepAliveTime in OPC UA

Post by mrahman252003 »

Thanks for reply, what does it mean in practice, is the subscription is deleted after that time? If subscription is expired how client can re initialize it by C# application client?
I have a problem in our application that sometimes client doesn't update the UI (though there is datachange in server)and if I restart the client application then it starts to work again. Just wonder what could be the issues here. Our client is written in C#

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

Re: Subscription Lifetime and MaxKeepAliveTime in OPC UA

Post by Support Team »

Hello mrahman252003,

the lifetime only expires if the client stops sending publish requests which never happens in normal operation. The SDK (client side) takes care of that. If you stop getting data that probably has a different reason.
If the client reconnects or the subscription gets invalid the SDK should handle the situation gracefully.

1) Did you implement the subscription callbacks in your client'? If the subscription gets invalid the SDK will inform you about that.
See:
http://documentation.unified-automation ... 28a1ecbc5f

2) Turn on the trace and see what happens
See:
http://documentation.unified-automation ... raceLevels
Best regards
Unified Automation Support Team

mrahman252003
Sr. Member
Sr. Member
Posts: 13
Joined: 18 Feb 2016, 21:47

Re: Subscription Lifetime and MaxKeepAliveTime in OPC UA

Post by mrahman252003 »

Hi,
We have implemented but it does not take any action (this is not my work, I just inherited from other). I see the following logs are printed
changed from Created to WarningKeepAliveLate (BadCommunicationError) by the code

Code: Select all

        private void SubscriptionOnStatusChanged(Subscription subscription, SubscriptionStatusChangedEventArgs statusChangedEventArgs)
        {
            // TODO: any problems occurring with subscriptions should be handled accordingly
            log.InfoFormat("changed from {2} to {3} ({4})",  statusChangedEventArgs.OldStatus, statusChangedEventArgs.CurrentStatus, statusChangedEventArgs.Error);
           ...
Most time, after the connection breaks, client get connected automatically but sometimes it does not. When connection is reestablished the I see the following logs are printed

Code: Select all

changed from Deleted to Created (Good)
Do you think, if I see Created status then I should create new subscription ? But I see we are calling the subscription creation method when we get connection status changed to connected. Sometimes, somehow it miss the subscription and UI is not updated. Is it harmful if I create subscription 2 times to make sure we have subscription? Biggest problem here, I can't reproduce the error, no idea when it occurs.

Post Reply