Not a bug

Subscription not working

Elio 1 year ago in OPCUA4Unity updated 11 months ago 16

Hello, we found some problem using the subscription method. Initially we used the polling method (not recommended), but eventually we found out that this starts failing when we try to capture values from different servers at the same time.

Here is the project attached with some debug lines added. We are using Integration Objects OPC UA server to test the subscription.

Some more details:

- On Start() we can see that the interface is launched. We are subscribing 6 values, debug lines:

Image 927

- On OnConnected() we can see the subscription is done, but always for the same ClientHandle (is that correct?):

Image 928

No relevant errors are shown, and the values are being received properly at method OnSubscriptionValueChanged() at OPCUA_Interface.cs .

Are the values not updated correctly?

Can you please describe more how I should use your demonstration model you putted on our upload platform?

Correct, our problem is the following:

We are trying to use the recommended subscription method to get the values of 6 robot axis. In NodeControl.cs you can see that we are using Start(), OnConnected(), NodeChanged() and Update() methods as described in the documentation, but we never see NodeValue in NodeChanged() change. However, the interfaces and subscriptions seem to be working according to debug messages, and the values are being received at OPCUA_Interface.cs by the method OnSubsriptionValueChanged(). So it appears that the library is working, but we can not get the values using the recommended method.

Previously we tried using the "Not recommended method", polling the values constantly and it works... But the scalability was an issue when we tried to include more than one data source.

Ok will need to check. As an intermediate solution you could change to the latest release. There you can define a poll cycle for each node so the performance issue is solved when polling.

One more question - for me to be able to test. Is it a special issue when using multiple OPCUA interfaces in one scene or is it a generic issue also with one interface?

It happens always, with only one or many

For the subscriptions I am totally sure that they are working. Is there a demo model with a demo opcua server where I can check your setup.

Could you share your project? I want to test it on my setup, I am using virtual machines and I want to be sure there is no issue with that... And which version of the library are you using? Can you share it too?


I have the following error:

Image 932

Any idea about what is missing?


We have tested the last version. As a consequence of that, we have verified that the OPCUA server's values readings are right, without any data loss inside the function known as OnValueChanged() (OPCUA node). However, inside the function update(), where we make the joint rotation, we have detected that, sometimes, some values are missed / skipped.

This is a debug example extracted from the Unity console (we have used a local OPCUA simulator to avoid latency problems, as well as we have used 100 milliseconds as update time for the OPC UA variables):

OnValueChanged reads 17

Update reads 17 ( 18 times)

OnValueChanged reads 18

OnValueChanged reads 19

Update reads 19 (14 times)

What we have observed is that, despite the fact that the function update() is much faster that the 100 ms (10 Hz) used by the OPC UA simulator, sometimes some values are missed/skipped. Indeed, the function update() reads several times the same value, which proves that it is running very fast.

What may be the reason for this behaviour?

We have followed the examples provided by you to make the rotations, but we are still missing some values inside the funcion update().

Is there any time limit (in milliseconds) for the OPCUA simulation? Any threshold that we have to follow to avoid missing values?

We have also tested the same scenario using 300 milliseconds as a refresh rate in the OPC UA simulator, and we haven,' missed any value.


    Hi, OnValue changed is an event triggered function which is managed by the subscriptions and it depends how the OPCUA server is calling it. Update itself is called in a regular manner. I think you might get values in the subscriptions because these might tell you all changes which the update function might miss because it is called in a cyclic manner.


    Thank you for your answer, but I am afraid that information is not helping me (or maybe I don't know how to use it to solve the problem).

    I have been digging into the problem and, using Wireshark, I have been capable of watching the network data frames. One thing that I have discovered is this: When a value is missing, Unity receives, not a value, but a couple of them using a two elements array. More specifically, our OPC UA Server is updating the values each 100 milliseconds and, when a value is missing, the OPC UA server has sent, not one value, but two values. I don't know the reason but I venture to speculate that between the previous request and the new one, the OPC UA server has accumulated them.

    Theoretically that is not a problem, because there is a queue for that purpose and, indeed, the function "OnSubsriptionValueChanged()" can "open" the array and extract both values. However, when the funcion "FixedUpdate()" is called, only the most recent value of the array is used. The other value is missing.

    Any idea about this? Do you know whether this may be the origin of the problem?