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