# OpcSubscription Class

<dl class="api-definition">
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx.client">Opc.UaFx.Client</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
<dt>Members</dt>
<dd><a href="./members">OpcSubscription Members</a></dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

Provides mechanisms to monitor a set of attributes (= node data) and (node-related) events using notifications being reported from the server to the client.

## Syntax

<div class="api-signature" data-lang="csharp">

```csharp
public class OpcSubscription
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Class OpcSubscription
```

</div>

## Inheritance

[Object](https://learn.microsoft.com/dotnet/api/system.object) → **OpcSubscription**

## Remarks

When a subscription is created, the first message is sent at the end of the first publishing cycle to inform the client that the subscription is operational. Another message is sent if there are notifications ready to be reported. If there are none, a keep-alive message is sent instead that contains a sequence number of one, indicating that the first notification has not yet been sent. This is the only time a keep-alive message is sent without waiting for the maximum keep-alive count to be reached.

## Properties

| Name | Description |
|---|---|
| [Client](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#client)<span class="api-meta">since v2.15</span> | Gets the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) used to setup this OpcSubscription. |
| [CurrentKeepAliveCount](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#currentkeepalivecount) | Gets the actual keep-alive count used by the server for this OpcSubscription which has been negotiated by the server against the [KeepAliveCount](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#keepalivecount) requested to meet its own constraints. |
| [CurrentLifetimeCount](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#currentlifetimecount) | Gets the actual lifetime count used by the server for this OpcSubscription which has been negotiated by the server against the [LifetimeCount](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#lifetimecount) requested to meet its own constraints. |
| [CurrentPriority](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#currentpriority) | Gets the actual relative priority of the subscription used to priorize notifications being send then more than one subscription is to be notified. |
| [CurrentPublishingInterval](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#currentpublishinginterval) | Gets the actual publishing interval used by the server for this OpcSubscription which has been negotiated by the server against the [PublishingInterval](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#publishinginterval) requested to meet its own constraints. |
| [CurrentPublishingIsEnabled](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#currentpublishingisenabled) | Gets the actual value indicating whether publishing is enabled by the server for this OpcSubscription which has been created and validated by the server against its own constraints. |
| [DisplayName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#displayname) | Gets or sets the name of the OpcSubscription used just for display purpose in the client application. |
| [HasPendingChanges](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#haspendingchanges) | Gets a value indicating whether there exists any pending change on the subscription which needs to be applied to take effect ([ApplyChanges](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#applychanges)). |
| [Id](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#id) | Gets the server-assigned unique identifier for this OpcSubscription. |
| [IsCreated](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#iscreated) | Gets a value indicating whether this OpcSubscription has been created on the server. |
| [IsPublishing](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#ispublishing) | Gets a value indicating whether this OpcSubscription is receiving notifications. |
| [KeepAliveCount](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#keepalivecount) | Gets or sets a value which defines the requested number of times the publishing timer have to expire without any notification being sent before the server have to send a keep-alive message to the client. |
| [LastNotification](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#lastnotification) | Gets the last notification received from the server. |
| [LastNotificationTime](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#lastnotificationtime) | Gets the time the last notification which has been received from the server. |
| [LifetimeCount](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#lifetimecount) | Gets or sets a value which defines the requested number of times the publishing timer have to expire without any publish request before the server have to delete this OpcSubscription. |
| [MaxMessageCount](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#maxmessagecount) | Gets or sets the maximum number of notifications to keep in the cache. |
| [MaxNotificationsPerPublish](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#maxnotificationsperpublish) | Gets or sets a value which defines the maximum number of notifications that the client wants to receive in a single publish response. |
| [MinLifetimeInterval](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#minlifetimeinterval) | Gets or sets a value which defines the minimum lifetime interval to apply in respect of the [PublishingInterval](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#publishinginterval) and the [LifetimeCount](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#lifetimecount) configured. |
| [MonitoredItems](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#monitoreditems) | Gets a read-only collection of [OpcMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/) instances associated with this OpcSubscription. |
| [Notifications](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#notifications) | Gets a sequence of [OpcNotification](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnotification/) instances received from the server. |
| [Priority](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#priority) | Gets or sets a value which defines the relative priority of the subscription used to priorize notifications being send then more than one subscription is to be notified. |
| [PublishingInterval](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#publishinginterval) | Gets or sets the requested number of milliseconds of the interval within the server have to send cyclic notifications to the client. |
| [PublishingIsEnabled](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#publishingisenabled) | Gets or sets a value indicating whether publishing is enabled for this OpcSubscription. |
| [PublishTime](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#publishtime) | Gets the time the last notification was published from the server. |
| [ReceivedDataChangeCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#receiveddatachangecallback) | Gets or sets the callback used to process data changes of the monitored items associated with this OpcSubscription. |
| [ReceivedEventCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#receivedeventcallback) | Gets or sets the callback used to process events of the monitored items associated with this OpcSubscription. |
| [SequenceNumber](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#sequencenumber) | Gets the sequence number of the last notification which has been received from the server. |
| [Tag](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#tag) | Gets or sets the object that contains additional user data about the subscription. |
| [TimestampsToReturn](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#timestampstoreturn) | Gets or sets the timestamps the server shall transmit for each monitored item. |
| [UseMonitoredItemDataCache](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#usemonitoreditemdatacache) | Gets or sets a value indicating whether this OpcSubscription shall forward notifications received from the server to monitored item individual caches. |

## Methods

| Name | Description |
|---|---|
| [AddMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#addmonitoreditem)<span class="api-meta">15 overloads</span> | Adds the monitored item specified by `item` to this OpcSubscription. |
| [ApplyChanges](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#applychanges) | Applies any changes made on the current OpcSubscription or on one of its [MonitoredItems](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#monitoreditems) using the according services of the server connected to. |
| [ChangeMonitoringMode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#changemonitoringmode)<span class="api-meta">3 overloads</span> | Changes the monitoring mode of all [MonitoredItems](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#monitoreditems). |
| [GetMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#getmonitoreditem) | Retrieves the [OpcMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/) the `dataChange` specified belongs to. |
| [OnChanged](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#onchanged)<span class="api-meta">protected · virtual</span> | Raises the [Changed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#changed) event of the OpcSubscription. |
| [OnDataChangeReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#ondatachangereceived)<span class="api-meta">protected · virtual</span> | Raises the [DataChangeReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#datachangereceived) event of the OpcSubscription. |
| [OnEventReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#oneventreceived)<span class="api-meta">protected · virtual</span> | Raises the [EventReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#eventreceived) event of the OpcSubscription. |
| [OnIsPublishingChanged](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#onispublishingchanged)<span class="api-meta">protected · virtual</span> | Raises the [IsPublishingChanged](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#ispublishingchanged) event of the OpcSubscription. |
| [OnNotificationFailed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#onnotificationfailed)<span class="api-meta">protected · virtual · since v2.57</span> | Raises the [NotificationFailed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#notificationfailed) event of the OpcSubscription. |
| [OnNotificationReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#onnotificationreceived)<span class="api-meta">protected · virtual</span> | Raises the [NotificationReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#notificationreceived) event of the OpcSubscription. |
| [RefreshConditions](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#refreshconditions) | Forces the server to refresh all current conditions to synchronize the client with the server. |
| [RemoveMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#removemonitoreditem)<span class="api-meta">3 overloads</span> | Removes the monitored item specified by `item` from the [MonitoredItems](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#monitoreditems) of this OpcSubscription. |
| [ResendData](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#resenddata)<span class="api-meta">since v2.51</span> | Notifies the server to resend the current values of the [MonitoredItems](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#monitoreditems) monitoring data changes where the [MonitoringMode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/members#monitoringmode) is equals to [Reporting](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmonitoringmode/#reporting). |
| [StartPublishing](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#startpublishing) | Enables notifications being send from the server to the client for this OpcSubscription. |
| [StopPublishing](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#stoppublishing) | Disables notifications being send from the server to the client for this OpcSubscription. |
| [ToString](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#tostring)<span class="api-meta">override</span> | Returns a string that represents the current OpcSubscription. |
| [Unsubscribe](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#unsubscribe) | Deletes this OpcSubscription and all its [MonitoredItems](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#monitoreditems). |

## Events

| Name | Description |
|---|---|
| [Changed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#changed) | Occurs then a monitored is added, modified, deleted or changes on the OpcSubscription were applied. |
| [DataChangeReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#datachangereceived) | Occurs then a monitored item receives an event notification which is not handled by an [OpcDataChangeReceivedEventHandler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcdatachangereceivedeventhandler/) on its [DataChangeReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/members#datachangereceived) event. |
| [EventReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#eventreceived) | Occurs then a monitored item receives an event notification which is not handled by an [OpcEventReceivedEventHandler](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opceventreceivedeventhandler/) on its [EventReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/members#eventreceived) event. |
| [IsPublishingChanged](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#ispublishingchanged) | Occurs then the [IsPublishing](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#ispublishing) property has changed. |
| [NotificationFailed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#notificationfailed)<span class="api-meta">since v2.57</span> | Occurs then a notification message for this OpcSubscription failed to be received, so that its data changes and events do not reach the monitored items. |
| [NotificationReceived](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/members#notificationreceived) | Occurs then a [OpcNotification](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnotification/) for this OpcSubscription has been received by the session which owns this OpcSubscription. |

## Applies to

| Package | Versions |
|---|---|
| Opc.UaFx.Advanced | v2.5–v2.59 |
