.NET Based OPC UA Client/Server SDK

Table of Contents

API documentation UnifiedAutomation.UaClient.Subscription


The Subscription class represents a single Subscription on a Server. The Subscription maintains a local copy of the parameters and all MonitoredItems. These local copies can be altered by updating their properties without affecting the state on the Server. Actually affecting the state of the Server requires that one of the service methods be called.

The Subscription follows the same design pattern as the Session object where synchronous and asynchronous versions of each service call are defined. The RequestSettings is a parameter in each, and a single method call will be broken into multiple service requests if there are too many operations passed to the method.

The services supported by the Subscription object are shown in the following table:

Service NameDescription
CreateCreates a new Subscription on the Server.
Adds any MonitoredItems which are already part of the Subscription.
ModifyModifies the parameters of an existing Subscription.
DeleteDeletes an existing Subscription.
TransferTransfers a Subscription on the Server to this Session.
The application is responsible for ensuring MonitoredItems stored locally match the MonitoredItems that Server knows about.
CreateMonitoredItemsCreates one or more MonitoredItems.
ModifyMonitoredItemsModifies one or more MonitoredItems.
DeleteMonitoredItemsDeletes one or more MonitoredItems.
SetMonitoringModeChanges the monitoring mode for one or more MonitoredItems.
RepublishRequests that a notification message be resent by the Server.

The state of a Subscription can be saved or restored from a stream using the IEncoder and IDecoder interfaces. These allow Application Developers to choose a data format that suits their needs. Standard implementations for UA Binary and XML encodings are part of the SDK.

A Subscription object is thread-safe.

Reconnect Model

When a Session reconnects after an error, it has to recover its Subscriptions as well. The process used when recovering the Subscriptions is shown in the following diagram:


The TransferSubscription starts when the Session recovers a broken connection to the Server by creating a new Session. This action attempts to transfer the Subscription to the re-created Session. This will fail if too much time has passed and the Server has already cleaned up the Subscription.

The Republish action starts if the TransferSubscription action succeeds. Republishing repeats until all of the available sequence numbers returned in the TransferSubscription response have been processed. The CreateSubscription action starts if the TransferSubscription action fails. It creates a new Subscription on the Server using the locally cached parameters.

The CreateMonitoredItems action starts after the new Subscription is created. It re-creates all of the MonitoredItems that existed when communication failed.

The BeginPublish action re-fills the Session publish queue by sending a Publish request. At this point recovery is complete and the application will receive updates from the Server.