Hello, I've noticed a strange behaviour inside a client software I've developed, so I took a step back and made some test with a simple client console application (NET. Core on windows)
The code is the following:
// Define which server we will work with.
UAEndpointDescriptor endpointDescriptor = url;
endpointDescriptor.UserIdentity = UserIdentity.CreateUserNameIdentity(usr, pwd);
endpointDescriptor.UserName = usr;
endpointDescriptor.Password = pwd;
// Hook static events
EasyUAClient.LogEntry += EasyUAClientOnLogEntry;
// Instantiate the client object and hook events
var client = new EasyUAClient();
Console.WriteLine("Browsing event sources");
// Obtain event sources
UANodeElementCollection eventSourceNodeElementCollection = client.BrowseEventSources(endpointDescriptor, UAObjectIds.Server);
// Display event sources
if (eventSourceNodeElementCollection.Count != 0)
{
Console.WriteLine();
Console.WriteLine("Event sources:");
foreach (UANodeElement eventSourceNodeElement in eventSourceNodeElementCollection)
{
Console.Write("- ");
Console.WriteLine(eventSourceNodeElement);
}
}
UANodeElement eventSource = eventSourceNodeElementCollection.First();
client.EventNotification += client_EventNotification;
Console.WriteLine("Subscribing...");
client.SubscribeEvent(endpointDescriptor, eventSource, 1000, new UAAttributeFieldCollection
{
Operands.NodeId,
Operands.EventId,
Operands.EventType,
Operands.SourceNode,
Operands.SourceName,
Operands.Time,
Operands.ReceiveTime,
Operands.LocalTime,
Operands.Message,
Operands.Severity,
});
Console.WriteLine("Processing event notifications for 30 seconds...");
System.Threading.Thread.Sleep(30 * 1000);
Console.WriteLine("Unsubscribing...");
client.UnsubscribeAllMonitoredItems();
Console.WriteLine("Waiting for 5 seconds...");
System.Threading.Thread.Sleep(5 * 1000);
I have two different behaviour. In the first one, I've launched only the console application. Here's the output:
Subscribing...
[] Success
Processing event notifications for 30 seconds...
[] Success; Refresh; RefreshInitiated
[] Success; Refresh; RefreshComplete
Unsubscribing...
In the second one, I connected the server to another application (UaExpert, it's the tool I was given to compare my application output). Then I've launched my console application.
Subscribing...
[] Success
Processing event notifications for 30 seconds...
[] Success; Refresh; RefreshInitiated
[] Success; Refresh; (10 field results) [PLC] 500! "700551 | Porta 1 operatore aperta" @12/11/2020 10:30:31 PM
[] Success; Refresh; (10 field results) [PLC] 500! "700552 | Porta 2 operatore aperta" @12/11/2020 10:30:31 PM
[] Success; Refresh; (10 field results) [PLC] 500! "700553 | Porta 3 servizio aperta" @12/14/2020 9:43:46 AM
[] Success; Refresh; RefreshComplete
Unsubscribing...
There are previous active events in the refresh event (as I expected).
I think the problem lies somewhere in the configuration, but I cannot figure out where.
The big difficulty is that I cannot attach a debugger: I'm working remotely and the OPC-UA server is behind an ad-hoc network, so the testing involves the deploy on the production enviroment on a computer that can reach the server.
I've attacched the extended log of both runs.