# OpcClient.Connect Method

> Reference: Establishes a connection to the server identified by the ServerAddress and creates/activates a new session to access the OPC UA services provided by the server.

<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>

Establishes a connection to the server identified by the [ServerAddress](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/serveraddress) and creates/activates a new session to access the OPC UA services provided by the server.

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

```csharp
public void Connect()
```

</div>

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

```vbnet
Public Sub Connect()
```

</div>

**Exceptions**

| Exception | Condition |
|---|---|
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The [ServerAddress](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/serveraddress) is not specified. The value of [ServerAddress](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/serveraddress) is a null reference (Nothing in Visual Basic) or the method is currently not supported, because of the license has expired. |
| [LicenseException](https://learn.microsoft.com/dotnet/api/system.componentmodel.licenseexception) | The license is expired. |
| [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/) | This type of exception can have the following reasons: - [BadSecureChannelClosed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badsecurechannelclosed) The secure channel has been closed. This can have the following reasons: - Reason A The client certificate is unknown or untrusted by the server. - Solution A Store the client certificate in the servers certificate store for trusted certificates. - Solution B Use a different endpoint with the [OpcSecurityMode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritymode/) value [None](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritymode/#none) to connect to the server. |
