Advice writing C# client connecting to Ignition OPCUA server

I have written a C# windows service to monitor and process OPCUA tag data from an Ignition server. (Must be C# for various reasons out of my control, not my first time writing a windows service). I used the examples from the OPC foundation to write my code. However being a 24/7 application it is very unforgiving. Sometimes tags will change on the server and the topic change events will just stop in my application. No clue why.

My application must be very robust and OPCUA is mostly a big complicated mystery to me right now. I need to know more.

Specific things I would like to learn more about, but have not found anything very helpful yet:

  1. How do you know for sure when the OPCUA connection is broken and it is time to disconnect and reconnect ? Best I can come up with is using a heartbeat tag subscription but surly the OPCUA has a better solution. Using some of the properties and events that seem like they should provide this information are very inconsistent.

  2. How do you automate the testing of a OPCUA connection state ? How can I introduce network connection loss, busy networks, etc. so tests can be run before each software release to verify recovery is working ? ( I know… big topic)

  3. Am I better off purchasing a 3rd party toolkit ? Know any good ones ?

  4. Are there any good books that explain OPCUA (OPCUA for dummies ??:))

Any advice would be appreciated !

In theory, you don’t have to, because there are mechanisms within the protocol that prevent this. Subscriptions indicate they are still alive in the absence of data changes by sending back periodic empty keep alive PublishResponses instead of PublishResponses containing data.

Of course in practice this doesn’t defend against a broken server implementation. There’s not much you can do besides trust that a server is implementing subscriptions correctly.

But for the overall connection state…

I implement my own keep alive mechanism where the server’s State variable is read periodically. If the server ever fails to respond some number of consecutive times I tear the connection down and start over.

Maybe, but the C# code provided by the OPC Foundation is by far the closest of any of their source dumps to actually being a usable and functional SDK. All you’re really missing is the support and documentation you’d get from purchasing a toolkit from somebody. If you do purchase one I’d probably recommend Unified Automation as the vendor.

Don’t know. I learned by reading the specs and implementing OPC UA twice now over the last 10 years. Can’t say I’d recommend this approach, lol.

1 Like