Client reconnects with data loss

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

Moderator: uasdkjava

Post Reply
akorol
Sr. Member
Sr. Member
Posts: 10
Joined: 27 May 2011, 10:30

Client reconnects with data loss

Post by akorol »

Hi there,

I have a problem with data loss when the connection between client and server has been interrupted.
The client reconnects with this output:
ServerState changed from Unknown to Runnning
Subscription alive: ID=8 lastAlive=07.09.2011 10:29:50


But the client does not receive the data generated in the meanwhile. I recognized, that the reconnect created a new Session, but did not find a way to connect the old Session.

Are there other ways to prevent this data loss?

Thanks a lot and kind regards,
Andy
Last edited by akorol on 07 Feb 2013, 10:48, edited 1 time in total.

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

Re:Client reconnects with data loss

Post by Support Team »

Hello Andy,

OPC UA provides everything to make sure you are not losing data in short network interruption scenarios. To clarify the exact reconnect behavior, the OPC UA working group is currently adding a chapter to OPC UA Part 4 that describes the recommended behavior including the Republish handling.

Using Republish after the connection loss makes sure you are getting the notification messages sent by the server before detecting the connection error. But I am not sure if this solves your problem. You can see in the proposed text that the reconnect should not create a new Session. But if the client is able to transfer the Subscription to the new Session, Republish should deliver the missing data.

We need to check with the SDK developer when the SDK behavior will be updated to the proposed handling from the OPC UA working group. The C++ SDK is following already the first part of the proposal regarding the reconnect but the Republish handling is not implemented in the described way by any of the known SDKs.

Text from the draft of the specification update:

When Client and Server lose the connection, the Client shall re-establish the connection by creating a new SecureChannel and activating the Session with the Service ActivateSession. This assigns the new SecureChannel to the existing Session and allows the Client to reuse the Session and Subscriptions in the Server and to continue receiving the data and event Notifications without losing information provided the queues in the MonitoredItems are long enough.

The Client shall only create a new Session if ActivateSession fails.

The Client can verify if a Subscription is still available by using the Service Republish as described in this section.

When the connection gets lost, sent Publish responses may not have been received by the Client. The loss can be detected via the sequence number in the NotificationMessage and the Client can call Republish to request the missed NotificationMessages.

After re-establishing the connection the Client shall call Republish in a loop, starting with the next expected sequence number and incrementing the sequence number until the Server returns the status Bad_MessageNotAvailable. After receiving this status, the Client shall start sending Publish requests with the normal Publish handling. This sequence ensures that the lost NotificationMessages queued in the Server are not overwritten by new Publish responses.

Independent of the detailed recover strategy, the Client should make sure that it does not overwrite newer data in the Client with older values provided through Republish.


Best regards,
Unified Automation Support Team
Last edited by Support Team on 07 Feb 2013, 10:48, edited 1 time in total.
Best regards
Unified Automation Support Team

akorol
Sr. Member
Sr. Member
Posts: 10
Joined: 27 May 2011, 10:30

Re:Client reconnects with data loss

Post by akorol »

Dear Supporters,

if the client is able to transfer the Subscription to the new Session, Republish should deliver the missing data.
Unfortunately it seems, that the (sample-) client is not able to do this subscription transfer - not 'out of the box' nor could I find any methods at the sdk to force this behaviour.

the Client shall re-establish the connection by creating a new SecureChannel and activating the Session with the Service ActivateSession. This assigns the new SecureChannel to the existing Session and allows the Client to reuse the Session and Subscriptions in the Server and to continue receiving the data and event Notifications without losing information provided the queues in the MonitoredItems are long enough.
Sounds good, but same as above: does not work 'out of the box' nor by explicit implementation since I miss corresponding methods in the sdk.

The Client can verify if a Subscription is still available by using the Service Republish as described in this section.
Does not seem to be implemented in the sdk as well.

Or do I overlook something?

Thanks for your help and kind regards,
Andy
Last edited by akorol on 07 Feb 2013, 10:48, edited 1 time in total.

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

Re:Client reconnects with data loss

Post by Support Team »

Hello Andy,

The Client SDK tries a TransferSubscription automatically in the reconnect. It should work if the server supports the TransferSubscription service. It is normally used to support redundant clients.

The described reconnect logic should be done by the reconnect. But the current reconnect implementation is creating a new session and tries to transfer the subscription to the new session. The reconnect handling will be changed for upcoming version 1.3.

Best regards,
Unified Automation Support Team
Last edited by Support Team on 07 Feb 2013, 10:48, edited 1 time in total.
Best regards
Unified Automation Support Team

akorol
Sr. Member
Sr. Member
Posts: 10
Joined: 27 May 2011, 10:30

Re:Client reconnects with data loss

Post by akorol »

Dear supporters,
thanks for the info! Is there already an announced release date? - Or do you keep it like Debian: it's done when it's done :) (what in my opinion is not the badest way)

Kind regards,
Andy
Last edited by akorol on 07 Feb 2013, 10:48, edited 1 time in total.

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

Re:Client reconnects with data loss

Post by Support Team »

Hello Andy,

The planned release date is end of October 2011.

Since one of the main goals for the version 1.3 releases is to pass compliance testing, there may be some delays. Based on our experience with making the C++ and ANSI C SDK compliant and pass the UA compliance test, there can be time consuming issues since they may be caused by the compliance test tool which requires a discussion with the compliance working group or they may even require a clarification in the UA specification.

But you can get a beta version if required.

Best regards,
Unified Automation Support Team
Last edited by Support Team on 07 Feb 2013, 10:48, edited 1 time in total.
Best regards
Unified Automation Support Team

akorol
Sr. Member
Sr. Member
Posts: 10
Joined: 27 May 2011, 10:30

Re:Client reconnects with data loss

Post by akorol »

Thanks for the offer, but I will stay on the 1.2.3 until the official release. By now our requirements are satisfied and things are working well.

Looking forward to hear from you when the 1.3 comes out.

Kind regards,
Andy
Last edited by akorol on 07 Feb 2013, 10:48, edited 1 time in total.

jaro
Jr. Member
Jr. Member
Posts: 2
Joined: 20 Oct 2008, 14:41

Re:Client reconnects with data loss

Post by jaro »

Version 1.3.0 released today, has an automatic reconnect implementation in UaClient. It works as described above.

akorol
Sr. Member
Sr. Member
Posts: 10
Joined: 27 May 2011, 10:30

Re:Client reconnects with data loss

Post by akorol »

jaro wrote:
Version 1.3.0 released today, has an automatic reconnect implementation in UaClient. It works as described above.

Nice, just got the email!

Thanks and greets,
Andy

Post Reply