# OpcClientKeepAlive Members

> Reference: Provides keep-alive options used by a client to monitor an established connection and recover from unexpected disconnection.

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

## Fields

### DefaultInterval

<span class="api-meta">static</span>

Represents the default interval value that is used by the [OpcClientKeepAlive](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/) as initial value of the [Interval](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#interval) property.

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

```csharp
public static readonly int DefaultInterval
```

</div>

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

```vbnet
Public Shared ReadOnly DefaultInterval As Integer
```

</div>

**Field value**

[Int32](https://learn.microsoft.com/dotnet/api/system.int32)

## Properties

### Exception

Gets the exception information associated with the [Status](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#status) represented by the current [OpcClientKeepAlive](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/).

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

```csharp
public OpcException Exception { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Exception As OpcException
```

</div>

**Property value**

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

An instance of the [OpcException](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/) class in case there the [IsBad](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatus/members#isbad) is equals true for the [Status](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#status) offered; otherwise a null reference (Nothing in Visual Basic).

### Interval

Gets or sets the interval to control the period within the client shall "ping" the server to test (= keep alive) whether the connection is still established and working.

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

```csharp
public int Interval { get; set; }
```

</div>

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

```vbnet
Public Property Interval As Integer
```

</div>

**Property value**

[Int32](https://learn.microsoft.com/dotnet/api/system.int32)

The number of milliseconds used to "ping" / test the connection. The default value is [DefaultInterval](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#defaultinterval).

**Remarks**

This interval controls how much time elapses before a communication error is detected. In case there is no abnormality detected the [Updated](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#updated) event is raised each time this period elapses.

### IsActive

Gets a value indicating whether the keep alive mechanism is active and works on a healthy and established connection.

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

```csharp
public bool IsActive { get; }
```

</div>

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

```vbnet
Public ReadOnly Property IsActive As Boolean
```

</div>

**Property value**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the keep alive is mechanism is active; otherwise the value false.

### Message

Gets a value which describes the most recent outcome of the keep alive mechanism.

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

```csharp
public string Message { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Message As String
```

</div>

**Property value**

[String](https://learn.microsoft.com/dotnet/api/system.string)

A [string](https://learn.microsoft.com/dotnet/api/system.string) which either offeres the textual representation of the [Code](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatus/members#code) of the [Status](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#status) (if [IsBad](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatus/members#isbad) of [Status](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#status) is equals false) or the [Message](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#message) (alternatively the [Description](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatus/members#description) of the [Status](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#status)) in case there [IsBad](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatus/members#isbad) of [Status](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#status) is equals true.

### ServerState

Gets a value indicating the most recent known state of the server.

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

```csharp
public OpcServerState ServerState { get; }
```

</div>

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

```vbnet
Public ReadOnly Property ServerState As OpcServerState
```

</div>

**Property value**

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

One of the members defined by the [OpcServerState](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcserverstate/) enumeration.

**Remarks**

The value of this property is determined during the keep alive progress and represents the value published by the server using the value of the node known under the browse path '/Server/ServerStatus/State'.

### Status

Gets the status information associated with the most recent outcome of the keep alive operation.

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

```csharp
public OpcStatus Status { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Status As OpcStatus
```

</div>

**Property value**

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

An instance of the [OpcStatus](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatus/) class which offers additional information about the outcome of the most recent keep alive operation.

### Time

Gets the time at which the server did respond on the most recent sent keep alive message.

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

```csharp
public DateTime? Time { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Time As Date?
```

</div>

**Property value**

[Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[DateTime](https://learn.microsoft.com/dotnet/api/system.datetime)&gt;

The [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) at which the server did respond to the most recent keep alive request or a null reference (Nothing in Visual Basic) if there is no connection established to a server.

## Methods

### OnUpdated

<span class="api-meta">protected · virtual</span>

Raises the [Updated](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#updated) event of the [OpcClientKeepAlive](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/).

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

```csharp
protected virtual void OnUpdated(EventArgs e)
```

</div>

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

```vbnet
Protected Overridable Sub OnUpdated(e As EventArgs)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `e` | [EventArgs](https://learn.microsoft.com/dotnet/api/system.eventargs) | The event data. |

### ToString

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

| Overload | Description |
|---|---|
| [ToString()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#tostring-noparams)<span class="api-meta">override</span> | Returns a string representing the most recent [Time](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#time) and [Message](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#message) offered by the most recent keep alive operation. |
| [ToString(IFormatProvider)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#tostring-system-iformatprovider) | Returns a string representing the most recent [Time](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#time) and [Message](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#message) offered by the most recent keep alive operation formatted using the `provider` specified. |

#### ToString()

<span class="api-meta">override</span>

Returns a string representing the most recent [Time](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#time) and [Message](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#message) offered by the most recent keep alive operation.

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

```csharp
public override string ToString()
```

</div>

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

```vbnet
Public Overrides Function ToString() As String
```

</div>

**Returns**

[String](https://learn.microsoft.com/dotnet/api/system.string)

A string formatted using the [InvariantCulture](https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo.invariantculture) representing the [Time](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#time) and [Message](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#message) of the current [OpcClientKeepAlive](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/).

**Overrides**

[ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

#### ToString(IFormatProvider)

Returns a string representing the most recent [Time](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#time) and [Message](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#message) offered by the most recent keep alive operation formatted using the `provider` specified.

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

```csharp
public string ToString(IFormatProvider provider)
```

</div>

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

```vbnet
Public Function ToString(provider As IFormatProvider) As String
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `provider` | [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider) | The [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider) to use to format the [Time](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#time). |

**Returns**

[String](https://learn.microsoft.com/dotnet/api/system.string)

A string formatted using the `provider` specified representing the [Time](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#time) and [Message](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#message) of the current [OpcClientKeepAlive](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/).

## Events

### Updated

Occurs when a keep alive cycle completed and therefore the [ServerState](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#serverstate), [Time](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#time), [Exception](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#exception) and [Status](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#status) properties were updated accordingly.

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

```csharp
public event EventHandler Updated
```

</div>

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

```vbnet
Public Event Updated As EventHandler
```

</div>

**Event type**

[EventHandler](https://learn.microsoft.com/dotnet/api/system.eventhandler)

**Remarks**

In general this event is raised whenever a keep alive period elapses (see [Interval](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclientkeepalive/members#interval)) or an abnormal connection state is detected.
