Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Subscription/Unsubscription/Dispose with multiple clients

More
30 Dec 2022 15:08 #11393 by mpp
The tests are passing now, thank you.
The following user(s) said Thank You: support

Please Log in or Create an account to join the conversation.

More
30 Dec 2022 14:51 #11392 by support
Hello,

your expectations, and your code, are correct. This is a QuickOPC bug. Thanks for reporting it!
It should be now fixed. Please download the current release (5.70.525.1 or later), rebuild your project with it, and re-test.

Best regards
The following user(s) said Thank You: mpp

Please Log in or Create an account to join the conversation.

More
29 Dec 2022 16:50 - 29 Dec 2022 18:41 #11388 by mpp
Hi!

I'm using the latest nuget version 5.70.507.
I prepared this test to explain the issue I'm having with the EasyUAClients:
static readonly string _endpoint = "opc.tcp://<IP>:<PORT>";
static readonly string _variable = "ns=4;s=|var|<BOOLEAN_VARIABLE>";
 
[TestMethod]
public void TestSubscription_DisposeClient()
{
    EasyUAClient.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Clear();
    EasyUAClient.SharedParameters.EngineParameters.CertificateAcceptancePolicy.TrustedEndpointUrlStrings.Add(_endpoint);
 
    var client1 = MakeClient();
    var client1_suscriptionEventCounter = 0;
    client1.DataChangeNotification += (s, e) => client1_suscriptionEventCounter++;
 
    var client2 = MakeClient();
    var client2_suscriptionEventCounter = 0;
    client2.DataChangeNotification += (s, e) => client2_suscriptionEventCounter++;
 
    client1.WriteValue(_endpoint, _variable, true);
    client1.WriteValue(_endpoint, _variable, false);
 
    Thread.Sleep(2000);
 
    Assert.IsTrue(client1_suscriptionEventCounter > 0);
    Assert.IsTrue(client2_suscriptionEventCounter > 0);
 
    client1_suscriptionEventCounter = 0;
    client2_suscriptionEventCounter = 0;
    client1.UnsubscribeAllMonitoredItems();
    client1.Dispose();
 
    client2.WriteValue(_endpoint, _variable, true);
    client2.WriteValue(_endpoint, _variable, false);
    Thread.Sleep(500);
    client2.WriteValue(_endpoint, _variable, true);
    client2.WriteValue(_endpoint, _variable, false);
    Thread.Sleep(500);
    client2.WriteValue(_endpoint, _variable, true);
    client2.WriteValue(_endpoint, _variable, false);
    Thread.Sleep(500);
    client2.WriteValue(_endpoint, _variable, true);
    client2.WriteValue(_endpoint, _variable, false);
 
    Thread.Sleep(2000);
 
    Assert.AreEqual(0, client1_suscriptionEventCounter);
    Assert.IsTrue(client2_suscriptionEventCounter > 0);
}
 
private EasyUAClient MakeClient()
{
    var client = new EasyUAClient();
 
    var toSubscribe = 
        new EasyUAMonitoredItemArguments[]
        {
            new EasyUAMonitoredItemArguments(new UAAttributeArguments(_endpoint, _variable))
        };
 
    client.SubscribeMultipleMonitoredItems(toSubscribe);
 
    return client;
}

The test fails on the last Assert where I'm expecting the second client (the not disposed one) to maintain its subscription.
Is this the expected behavior or a bug?

I also tried the same test with a previous version that we were using 5.62.1032 and the test passes with that version.
With the new version I tried to set `true` to the `Isolated` property of the client and the test passes this way.
What are the drawbacks on using the clients in isolation?

Thanks,


Michele
Last edit: 29 Dec 2022 18:41 by mpp. Reason: More tests performed

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.045 seconds