How to tackle Client when Server reconnects

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

Moderator: uasdkcpp

Post Reply
er.raunakgupta
Hero Member
Hero Member
Posts: 37
Joined: 11 May 2017, 09:26

How to tackle Client when Server reconnects

Post by er.raunakgupta »

Dear All,

I am testing a C++ Sdk based Client-Server system in which the variables in UaExpert displays some raw voltage values from the hardware when starting the server. Similarly, there is an external Client which subscribes those nodes, recalculates then and send them back to the server to display them in UaExpert.

Normal scenario: - Everytime when I start the server and run the client, I see this calculation behavior which is running perfect. Also, whenever I reconnect my client (making sure the server running in the background), it always recalculated values from the raw values (using the standard C++ Sdk reconnection behaviour).

Now here is my case:- During the time both my client and server are running, and by chance the server restarts or reconnects, I see that the server displays the raw values in the UaExpert which are left untreated by the client (raw values not getting recalculated by the client). Somehow, the client perform the reconnection after the server restart and do not perform the recalculation.
How could I solve this case? Is there a standard way for this scenario in SDk example? Help would be appreciated.
Thanks and regards
rG

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

Re: How to tackle Client when Server reconnects

Post by Support Team »

Hello

Code: Select all

Somehow, the client perform the reconnection after the server restart and do not perform the recalculation.
We need to analyze what exactly the client is doing and which step doesn't succeed:

- Does the reconnection succeed?
- Does the client successfully recreate subscriptions?
- Does the client get NotificationMessages?
- Does the client successfully write values to the server?
Best regards
Unified Automation Support Team

er.raunakgupta
Hero Member
Hero Member
Posts: 37
Joined: 11 May 2017, 09:26

Re: How to tackle Client when Server reconnects

Post by er.raunakgupta »

Hi Support team,

The first three steps are performed excluding the last (client writing values to the server).

What I can see in my case is that after re-connection, there is no dataChange callback function called for writing the values to server.

Thanks
rG

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

Re: How to tackle Client when Server reconnects

Post by Support Team »

You're saying everything works fine but you don't ever receive a datachange? That doesn't make sense to me.
Please check each single step in as I described in the last message. Maybe you miss to check a status code at some point.
As a next step you could turn on the trace and see if you find any error.
Best regards
Unified Automation Support Team

er.raunakgupta
Hero Member
Hero Member
Posts: 37
Joined: 11 May 2017, 09:26

Re: How to tackle Client when Server reconnects

Post by er.raunakgupta »

Okay, so I think where I am wrong here is that the client is not getting a NotificationMessages. There is a successful reconnection, including delete old subscription, create new one and create monitored items. Then what should I do to get Notification to client, that the server is reconnected and need to perform action(calculations) on the node values and write back to server?
I am sorry to be very amateur on this as I am completely new to this topic. Here is the code which executes when the server reconnects.

Code: Select all

void ClientSubscription::subscriptionStatusChanged(OpcUa_UInt32 clientSubscriptionHandle, const UaStatus& status)
{
    OpcUa_ReferenceParameter(clientSubscriptionHandle);
    UaStatus result;
    if (!status.isGood())
    {
        result = deleteSubscription();
        if (result.isBad())
        {
            return;
        }
        result = createSubscription();
        if (result.isBad())
        {
            return;
        }
        result = createMonitoredItems();
        if (result.isBad())
        {
            return;
        }
        if (m_subscriptionEventHandler)
        {
            SubscriptionEventArgs args;
            args.eventType = SubscriptionEventArgs::RECONNECTION;
            m_subscriptionEventHandler->handleEvent(this, &args);
        }
    }
}
Thanks for help.
rG

er.raunakgupta
Hero Member
Hero Member
Posts: 37
Joined: 11 May 2017, 09:26

Re: How to tackle Client when Server reconnects

Post by er.raunakgupta »

Okay, so I cross checked. The error is in my implementation. It has nothing to do with SDK subscription stuff.
Thanks

Post Reply