nauful / LibUA

Open-source OPC UA client and server library
Apache License 2.0
262 stars 94 forks source link

CreateSubscription() receives data updates from simulated tags fluently, but not from actual PLC data updates, possible reason? #192

Closed xiaoyuvax closed 3 weeks ago

xiaoyuvax commented 3 weeks ago

Connecting to GE IGS, CreateSubscription() receives data updates from simulated tags fluently, but not from actual PLC data updates except for initial update immediately after subscription, no more data received, possible reason?

UaExpert monitors fluently too.

double requestedPublishingInterval = 0; 
uint maxNotificationsPerPublish = 2000;
byte priority = 0;

if (IsGood(CreateSubscription(requestedPublishingInterval, maxNotificationsPerPublish, true, priority, out uint subscrId)))
{
                SetPublishingMode(true, [subscrId], out uint[] respStatuses);

                var monitorRequests = tagsToMonitor.Select((i, n) => new MonitoredItemCreateRequest(i,
                    MonitoringMode.Reporting, new MonitoringParameters((uint)n, 0, null, 100, false))).ToArray();

                if (IsGood(CreateMonitoredItems(subscrId, TimestampsToReturn.Both, monitorRequests, out MonitoredItemCreateResult[] monitorCreateResults)))
                {...}
}
nauful commented 3 weeks ago

What happens if you use Sampling instead of Reporting, with a sampling interval of 500ms?

xiaoyuvax commented 3 weeks ago

I made a test program exactly with the TestClient code from LibUA demos (the latest pull), in which:

client.CreateMonitoredItems(subscrId, TimestampsToReturn.Both,
                [
                    new MonitoredItemCreateRequest(
                        new ReadValueId(new NodeId(2, args[1]), NodeAttribute.Value, null, new QualifiedName()),  
                        MonitoringMode.Sampling,
                        new MonitoringParameters(clientHanlder, 500, null, 100, false)),
                ], out monitorCreateResults);
nauful commented 3 weeks ago

Can you share a Wireshark capture with security set to None with uaexpert, then with your libua client?

xiaoyuvax commented 3 weeks ago

Sorry, not possible so far, it's found in a production environment. I don't even have similar environment to reproduce it locally, as is my headache too, otherwise, i would have located the line causing the problem in the source. Finally, I had to reimplement and done the client with h-opc-cli, and it works perfectly after i forked it and made minor changes. If any further discovery, i'll infom here.

nauful commented 3 weeks ago

It's difficult to say what might be different because it could be anything from subscription configuration to connection/auth configuration.