# OpcClient.SubscribeNodes Method

> Reference: Creates a OpcSubscription using the OpcMonitoredItem setup defined by the commands specified.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcClient</a></dd>
<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">OpcClient Members</a></dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

<span class="api-meta">2 overloads</span>

| Overload | Description |
|---|---|
| [SubscribeNodes(IEnumerable&lt;OpcSubscribeNode&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/subscribenodes#subscribenodes-system-collections-generic-ienumerable-of-opc-uafx-client-opcsubscribenode) | Creates a [OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/) using the [OpcMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/) setup defined by the `commands` specified. |
| [SubscribeNodes(params OpcSubscribeNode\[\])](#subscribenodes-opc-uafx-client-opcsubscribenode-array) | Creates a [OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/) using the [OpcMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/) setup defined by the `commands` specified. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The subscription service is currently not supported, especially using the arguments specified. |
| [ObjectDisposedException](https://learn.microsoft.com/dotnet/api/system.objectdisposedexception) | The object has been disposed of. |
| [OpcException](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/) | The service execution failed upon different circumstances; for more details see exception details. The following issues can lead to that exception: [BadNothingToDo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnothingtodo), [BadTooManyOperations](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtoomanyoperations), [BadTimestampsToReturnInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtimestampstoreturninvalid), [BadSubscriptionIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badsubscriptionidinvalid), [BadMonitoringModeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badmonitoringmodeinvalid), [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid), [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown), [BadAttributeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badattributeinvalid), [BadIndexRangeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badindexrangeinvalid), [BadIndexRangeNoData](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badindexrangenodata), [BadDataEncodingInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baddataencodinginvalid), [BadDataEncodingUnsupported](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baddataencodingunsupported), [BadMonitoredItemFilterInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badmonitoreditemfilterinvalid), [BadMonitoredItemFilterUnsupported](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badmonitoreditemfilterunsupported), [BadFilterNotAllowed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badfilternotallowed), [BadTooManySubscriptions](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtoomanysubscriptions) and [BadTooManyMonitoredItems](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtoomanymonitoreditems). |

## SubscribeNodes(IEnumerable&lt;OpcSubscribeNode&gt;)

Creates a [OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/) using the [OpcMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/) setup defined by the `commands` specified.

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

```csharp
public OpcSubscription SubscribeNodes(IEnumerable<OpcSubscribeNode> commands)
```

</div>

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

```vbnet
Public Function SubscribeNodes(
    commands As IEnumerable(Of OpcSubscribeNode)) As OpcSubscription
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `commands` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcSubscribeNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscribenode/)&gt; | A sequence of [OpcSubscribeNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscribenode/) commands which are used to define the [OpcMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/)'s used by the [OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/) created. |

**Returns**

[OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/)

A new instance of the [OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/) class with [OpcMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/)'s setup with the information specified. The kind of monitored item and how it is used by the subscription depends on the number, type and values passed to the different [OpcSubscribeNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscribenode/) commands.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `commands` or one of the items in the sequence is a null reference (Nothing in Visual Basic). |
| [LicenseException](https://learn.microsoft.com/dotnet/api/system.componentmodel.licenseexception) | The license is expired. |

## SubscribeNodes(params OpcSubscribeNode\[\])

Creates a [OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/) using the [OpcMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/) setup defined by the `commands` specified.

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

```csharp
public OpcSubscription SubscribeNodes(params OpcSubscribeNode[] commands)
```

</div>

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

```vbnet
Public Function SubscribeNodes(
    ParamArray commands As OpcSubscribeNode()) As OpcSubscription
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `commands` | params [OpcSubscribeNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscribenode/)[] | An array of [OpcSubscribeNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscribenode/) commands which are used to define the [OpcMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/)'s used by the [OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/) created. |

**Returns**

[OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/)

A new instance of the [OpcSubscription](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscription/) class with [OpcMonitoredItem](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcmonitoreditem/)'s setup with the information specified. The kind of monitored item and how it is used by the subscription depends on the number, type and values passed to the different [OpcSubscribeNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcsubscribenode/) commands.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `commands` or one of the items in the array is a null reference (Nothing in Visual Basic). |
