Traeger-GmbH / opcuanet-samples

Sample projects for C#, VB.NET and C++/CLI to guide developers using our OPC UA .NET SDKs.
https://opcua.traeger.de
MIT License
88 stars 39 forks source link

Event Subscription not working #9

Closed asacchettacali closed 1 year ago

asacchettacali commented 1 year ago

Hello, I tried to implement the example illustrated here but unfortunately the event pub / sub doesn't seem to work on either my MacOS and Windows:

Screenshot 2023-04-18 at 15 16 35

Can you help me? Thank you

janbiehl commented 1 year ago

Hey, i had the same issue. I tried to rollback to an older version and this fixed the error for me.

So i am not using the latest 2.30.0. Instead im am using 2.29.0 and the code just works without further changes.

image

kpreisser commented 1 year ago

Hi, thanks for creating this issue! Can you try to create an OpcEventFilter and pass it to client.SubscribeEvent(), like this:

var eventFilter = OpcFilter.Using(client).FromEvents(OpcEventTypes.Event).Select();
client.SubscribeEvent(OpcObjectTypes.Server, eventFilter, HandleGlobalEvents);

There seems to be an issue in the current version of the OPC UA .NET SDK, which causes the event subscription to not work if no OpcEventFilter is specified (that defines the event fields that the server sends to the client). We are currently investiaging this issue.

Thanks!

asacchettacali commented 1 year ago

Hello,

Thank you for the suggestion, it now works correctly.

Cheers, Alessio

kpreisser commented 1 year ago

Hi, sorry that it took so long, but we have now fixed the issue that the event subscription doesn't work (since v2.29.0) when no OpcEventFilter is specified. The fix will be included in OPC UA .NET SDK v2.40.0, which we will release today or tomorrow.

Thanks again for reporting this!