Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to subscribe to an ExtensionObject or nested value array #171

Closed
Christ0ph89 opened this issue Jul 1, 2024 · 10 comments
Closed

How to subscribe to an ExtensionObject or nested value array #171

Christ0ph89 opened this issue Jul 1, 2024 · 10 comments

Comments

@Christ0ph89
Copy link

Hi Nauful,

I'm trying to subscribe to an ExtensionObject, which contains two sub-levels of value arrays, without success actually. I'm note sure, if it is even possible, since in the opc ua specification is written: Objects and views can be used to monitor Events Ref.

Why I'm asking, if I subscribe to that specific node id in UAExpert from UnifiedAutomation, the Source and Server Timestamp is updated all the time on any value change in the sub tree of that node. If I subscribe, with NodeAttribute.Value, to that specific node in LibUA, nothing happens. Also UAExperts tell me, it's an mentioned ExtensionObject.

Can you tell me what I'm missing or is it a feature that is still not implemented in LibUA?

Here is an picture of the attributes of that specific node, which shows the sub-levels of the value arrays:
Inkedsub_array_subscribe_LI (2)

@Magniveo
Copy link

Magniveo commented Jul 2, 2024

Hello, you can see the implementation in the TestClient project, and the implementation of the subscription for the server in the TestServer project.

@nauful
Copy link
Owner

nauful commented Jul 2, 2024

Hello,

Can you capture subscribing via uaexpert in Wireshark with no security and share that here? I would guess it subscribed to something besides (nodeid, value).

@Christ0ph89
Copy link
Author

Hi Nauful,

sure, I've capture the traffic from UAExpert and the LibUA client for the mentioned node, which is now ns=4;i=2801; after an structure update on the OPC server. The according dump is named after that at the end (..._libua / ..._uaexpert).

What I've seen so far, the requests are nearly the same for the specific node, but in the LibUA client, the "NotifyDataChangeNotifications" method is not fired on an publish response for that node. Maybe there is some filter or switch case missing in LibUA?

opc_nodeid_subscribe_libua.zip
opc_nodeid_subscribe_uaexpert.zip

@nauful
Copy link
Owner

nauful commented Jul 3, 2024

Hmm, it looks like that should have worked. Please check this line and step through to see if it reaches the call to NotifyDataChangeNotifications:

DataValue[] notifications = new DataValue[numDv];

If decoding succeeds, it should call NotifyDataChangeNotifications. You override that in your client, for example:

public override void NotifyDataChangeNotifications(uint subscrId, uint[] clientHandles, DataValue[] notifications)

@Christ0ph89
Copy link
Author

Thanks for the hint. I've stepped through the code and found the failing part in the Client.cs on line 4299, where the call succeeded &= recvHandler.RecvBuf.Decode(out notifications[j]); returns 'false'.
Digging deeper in the stack, it tries to decode the notification as variant in MemoryBufferExtensions.cs on line 1194. Finally in the VariantDecode function in MemoryBuffer.cs line 635, it fails on line 644, where if ((mask & 0x80) != 0) is always 0.

Maybe the ExtensionObject has a different mask and need to be handle separately in the MemoryBufferExtensions.cs?

@nauful
Copy link
Owner

nauful commented Jul 3, 2024

Thanks, that gives me a hint. Let me investigate. I don't think I've seen an extension object in a variant before so this is a new case.

@nauful
Copy link
Owner

nauful commented Jul 3, 2024

Fixed, let me know if the latest version works.

@Christ0ph89
Copy link
Author

Looks good, great work 👍 . The only thing that seems to be missing is the source timestamp, the server timestamp is correct in the notification. Maybe another bug?

@nauful
Copy link
Owner

nauful commented Jul 3, 2024

There's no source timestamp in the data:
image

uaexpert requested both timestamps:
image

In your CreateMonitoredItemsRequest, request both source and server timestamps:
image

@Christ0ph89
Copy link
Author

Okay that was my fault, sorry for that 👍 .

Thanks again for the fast response and quick fix, everything is working now like expected :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants