# VcnGatewayConnectionConfig.Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#inhmethods)  

# VcnGatewayConnectionConfig.Builder

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/net/vcn/VcnGatewayConnectionConfig.Builder "View this page in Kotlin")\|Java

`
public
static
final

class
VcnGatewayConnectionConfig.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|----------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.vcn.VcnGatewayConnectionConfig.Builder |

<br />

*** ** * ** ***

This class is used to incrementally build[VcnGatewayConnectionConfig](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig)objects.

## Summary

|                                                                                                                                                                                                                      ### Public constructors                                                                                                                                                                                                                       ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#Builder(java.lang.String,%20android.net.ipsec.ike.IkeTunnelConnectionParams))`(`[String](https://developer.android.com/reference/java/lang/String)` gatewayConnectionName, `[IkeTunnelConnectionParams](https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams)` tunnelConnectionParams) ` Construct a Builder object. |

|                                                                                                                                                                                                                                                                                                                                       ### Public methods                                                                                                                                                                                                                                                                                                                                       ||
|-------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | ` `[addExposedCapability](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#addExposedCapability(int))`(int exposedCapability) ` Add a capability that this VCN Gateway Connection will support.                                                                                                                                                                                                                                                                                                                 |
| ` `[VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | ` `[addGatewayOption](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#addGatewayOption(int))`(int option) ` Enables the specified VCN gateway option.                                                                                                                                                                                                                                                                                                                                                          |
| ` `[VcnGatewayConnectionConfig](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig)                 | ` `[build](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#build())`() ` Builds and validates the VcnGatewayConnectionConfig.                                                                                                                                                                                                                                                                                                                                                                                  |
| ` `[VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | ` `[removeExposedCapability](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#removeExposedCapability(int))`(int exposedCapability) ` Remove a capability that this VCN Gateway Connection will support.                                                                                                                                                                                                                                                                                                        |
| ` `[VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | ` `[removeGatewayOption](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#removeGatewayOption(int))`(int option) ` Resets (disables) the specified VCN gateway option.                                                                                                                                                                                                                                                                                                                                          |
| ` `[VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | ` `[setMaxMtu](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#setMaxMtu(int))`(int maxMtu) ` Sets the maximum MTU allowed for this VCN Gateway Connection.                                                                                                                                                                                                                                                                                                                                                    |
| ` `[VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | ` `[setMinUdpPort4500NatTimeoutSeconds](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#setMinUdpPort4500NatTimeoutSeconds(int))`(int minUdpPort4500NatTimeoutSeconds) ` Sets the maximum supported IKEv2/IPsec NATT keepalive timeout.                                                                                                                                                                                                                                                                        |
| ` `[VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | ` `[setRetryIntervalsMillis](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#setRetryIntervalsMillis(long[]))`(long[] retryIntervalsMs) ` Set the retry interval between VCN establishment attempts upon successive failures.                                                                                                                                                                                                                                                                                  |
| ` `[VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | ` `[setSafeModeEnabled](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#setSafeModeEnabled(boolean))`(boolean enabled) ` Enable/disable safe mode If a VCN fails to provide connectivity within a system-provided timeout, it will enter safe mode.                                                                                                                                                                                                                                                            |
| ` `[VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | ` `[setVcnUnderlyingNetworkPriorities](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder#setVcnUnderlyingNetworkPriorities(java.util.List<android.net.vcn.VcnUnderlyingNetworkTemplate>))`(`[List](https://developer.android.com/reference/java/util/List)`<`[VcnUnderlyingNetworkTemplate](https://developer.android.com/reference/android/net/vcn/VcnUnderlyingNetworkTemplate)`> underlyingNetworkTemplates) ` Set the list of templates to match underlying networks against, in high-to-low priority order. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Builder (String gatewayConnectionName, 
                IkeTunnelConnectionParams tunnelConnectionParams)
```

Construct a Builder object.

<br />

|                                                                                                                                                                                                                                                                           Parameters                                                                                                                                                                                                                                                                            ||
|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `gatewayConnectionName`  | `String`: the String GatewayConnection name for this VcnGatewayConnectionConfig. Each VcnGatewayConnectionConfig within a[VcnConfig](https://developer.android.com/reference/android/net/vcn/VcnConfig)must be given a unique name. This name is used by the caller to distinguish between VcnGatewayConnectionConfigs configured on a single[VcnConfig](https://developer.android.com/reference/android/net/vcn/VcnConfig). This will be used as the identifier in VcnStatusCallback invocations. This value cannot be`null`. <br /> |
| `tunnelConnectionParams` | `IkeTunnelConnectionParams`: the IKE tunnel connection configuration This value cannot be`null`. <br />                                                                                                                                                                                                                                                                                                                                                                                                                               |

|                                                                                        Throws                                                                                         ||
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the provided IkeTunnelConnectionParams is not configured to support MOBIKE |

**See also:**

- [IkeTunnelConnectionParams](https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams)
- [VcnManager.VcnStatusCallback.onGatewayConnectionError(String, int, Throwable)](https://developer.android.com/reference/android/net/vcn/VcnManager.VcnStatusCallback#onGatewayConnectionError(java.lang.String,%20int,%20java.lang.Throwable))

## Public methods

### addExposedCapability

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public VcnGatewayConnectionConfig.Builder addExposedCapability (int exposedCapability)
```

Add a capability that this VCN Gateway Connection will support.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ||
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `exposedCapability` | `int`: the app-facing capability to be exposed by this VCN Gateway Connection (i.e., the capabilities that this VCN Gateway Connection will support). Value is[NetworkCapabilities.NET_CAPABILITY_MMS](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_MMS),[NetworkCapabilities.NET_CAPABILITY_SUPL](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_SUPL),[NetworkCapabilities.NET_CAPABILITY_DUN](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_DUN),[NetworkCapabilities.NET_CAPABILITY_FOTA](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_FOTA),[NetworkCapabilities.NET_CAPABILITY_IMS](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_IMS),[NetworkCapabilities.NET_CAPABILITY_CBS](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_CBS),[NetworkCapabilities.NET_CAPABILITY_IA](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_IA),[NetworkCapabilities.NET_CAPABILITY_RCS](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_RCS),[NetworkCapabilities.NET_CAPABILITY_XCAP](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_XCAP),[NetworkCapabilities.NET_CAPABILITY_EIMS](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_EIMS),[NetworkCapabilities.NET_CAPABILITY_INTERNET](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_INTERNET), or[NetworkCapabilities.NET_CAPABILITY_MCX](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_MCX) <br /> |

|                                                                                                                                               Returns                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | this[Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder)instance, for chaining This value cannot be`null`. <br /> |

**See also:**

- [for a list of capabilities may be exposed by a Gateway
Connection](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig)  

### addGatewayOption

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public VcnGatewayConnectionConfig.Builder addGatewayOption (int option)
```

Enables the specified VCN gateway option.

<br />

|                                                                                                                                            Parameters                                                                                                                                             ||
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `option` | `int`: the option to be enabled Value is[VcnGatewayConnectionConfig.VCN_GATEWAY_OPTION_ENABLE_DATA_STALL_RECOVERY_WITH_MOBILITY](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig#VCN_GATEWAY_OPTION_ENABLE_DATA_STALL_RECOVERY_WITH_MOBILITY) <br /> |

|                                                                                                                                               Returns                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | this[Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder)instance, for chaining This value cannot be`null`. <br /> |

|                                                                  Throws                                                                   ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the provided option is invalid |

### build

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public VcnGatewayConnectionConfig build ()
```

Builds and validates the VcnGatewayConnectionConfig.

<br />

|                                                                                                Returns                                                                                                ||
|------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
| [VcnGatewayConnectionConfig](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig) | an immutable VcnGatewayConnectionConfig instance This value cannot be`null`. <br /> |

### removeExposedCapability

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public VcnGatewayConnectionConfig.Builder removeExposedCapability (int exposedCapability)
```

Remove a capability that this VCN Gateway Connection will support.

<br />

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ||
|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `exposedCapability` | `int`: the app-facing capability to not be exposed by this VCN Gateway Connection (i.e., the capabilities that this VCN Gateway Connection will support) Value is[NetworkCapabilities.NET_CAPABILITY_MMS](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_MMS),[NetworkCapabilities.NET_CAPABILITY_SUPL](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_SUPL),[NetworkCapabilities.NET_CAPABILITY_DUN](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_DUN),[NetworkCapabilities.NET_CAPABILITY_FOTA](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_FOTA),[NetworkCapabilities.NET_CAPABILITY_IMS](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_IMS),[NetworkCapabilities.NET_CAPABILITY_CBS](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_CBS),[NetworkCapabilities.NET_CAPABILITY_IA](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_IA),[NetworkCapabilities.NET_CAPABILITY_RCS](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_RCS),[NetworkCapabilities.NET_CAPABILITY_XCAP](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_XCAP),[NetworkCapabilities.NET_CAPABILITY_EIMS](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_EIMS),[NetworkCapabilities.NET_CAPABILITY_INTERNET](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_INTERNET), or[NetworkCapabilities.NET_CAPABILITY_MCX](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_MCX) <br /> |

|                                                                                                                                               Returns                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | this[Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder)instance, for chaining This value cannot be`null`. <br /> |

**See also:**

- [for a list of capabilities may be exposed by a Gateway
Connection](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig)  

### removeGatewayOption

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public VcnGatewayConnectionConfig.Builder removeGatewayOption (int option)
```

Resets (disables) the specified VCN gateway option.

<br />

|                                                                                                                                             Parameters                                                                                                                                             ||
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `option` | `int`: the option to be disabled Value is[VcnGatewayConnectionConfig.VCN_GATEWAY_OPTION_ENABLE_DATA_STALL_RECOVERY_WITH_MOBILITY](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig#VCN_GATEWAY_OPTION_ENABLE_DATA_STALL_RECOVERY_WITH_MOBILITY) <br /> |

|                                                                                                                                               Returns                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | this[Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder)instance, for chaining This value cannot be`null`. <br /> |

|                                                                  Throws                                                                   ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the provided option is invalid |

### setMaxMtu

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public VcnGatewayConnectionConfig.Builder setMaxMtu (int maxMtu)
```

Sets the maximum MTU allowed for this VCN Gateway Connection.

This MTU is applied to the VCN Gateway Connection exposed Networks, and represents the MTU of the virtualized network.

The system may reduce the MTU below the maximum specified based on signals such as the MTU of the underlying networks (and adjusted for Gateway Connection overhead).

<br />

|                                                                                                                             Parameters                                                                                                                              ||
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `maxMtu` | `int`: the maximum MTU allowed for this Gateway Connection. Must be greater than the IPv6 minimum MTU of 1280. Defaults to 1500. Value is[ERROR(/android.net.vcn.VcnGatewayConnectionConfig#MIN_MTU_V6)](https://developer.android.com/)or greater <br /> |

|                                                                                                                                               Returns                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | this[Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder)instance, for chaining This value cannot be`null`. <br /> |

### setMinUdpPort4500NatTimeoutSeconds

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public VcnGatewayConnectionConfig.Builder setMinUdpPort4500NatTimeoutSeconds (int minUdpPort4500NatTimeoutSeconds)
```

Sets the maximum supported IKEv2/IPsec NATT keepalive timeout.

This is used as a power-optimization hint for other IKEv2/IPsec use cases (e.g. VPNs, or IWLAN) to reduce the necessary keepalive frequency, thus conserving power and data.

<br />

|                                                                                                                                                                                                                     Parameters                                                                                                                                                                                                                      ||
|-----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `minUdpPort4500NatTimeoutSeconds` | `int`: the maximum keepalive timeout supported by the VCN Gateway Connection, generally the minimum duration a NAT mapping is cached on the VCN Gateway; or[ERROR(/MIN_UDP_PORT_4500_NAT_TIMEOUT_UNSET)](https://developer.android.com/)to clear this value. Value is[ERROR(/android.net.vcn.VcnGatewayConnectionConfig#MIN_UDP_PORT_4500_NAT_TIMEOUT_SECONDS)](https://developer.android.com/)or greater <br /> |

|                                                                                                                                               Returns                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | this[Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder)instance, for chaining This value cannot be`null`. <br /> |

### setRetryIntervalsMillis

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public VcnGatewayConnectionConfig.Builder setRetryIntervalsMillis (long[] retryIntervalsMs)
```

Set the retry interval between VCN establishment attempts upon successive failures.

The last retry interval will be repeated until safe mode is entered, or a connection is successfully established, at which point the retry timers will be reset. For power reasons, the last (repeated) retry interval MUST be at least 15 minutes.

Retry intervals MAY be subject to system power saving modes. That is to say that if the system enters a power saving mode, the retry may not occur until the device leaves the specified power saving mode. Intervals are sequential, and intervals will NOT be skipped if system power saving results in delaying retries (even if it exceed multiple retry intervals).

Each Gateway Connection will retry according to the retry intervals configured, but if safe mode is enabled, all Gateway Connection(s) will be disabled.

<br />

|                                                                                                                                           Parameters                                                                                                                                           ||
|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `retryIntervalsMs` | `long`: an array of between 1 and 10 millisecond intervals after which the VCN will attempt to retry a session initiation. The last (repeating) retry interval must be at least 15 minutes. Defaults to:`[1s, 2s, 5s, 30s, 1m, 5m, 15m]`This value cannot be`null`. <br /> |

|                                                                                                                                               Returns                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | this[Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder)instance, for chaining This value cannot be`null`. <br /> |

**See also:**

- [for additional discussion on fail-safe mode](https://developer.android.com/reference/android/net/vcn/VcnManager)  

### setSafeModeEnabled

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public VcnGatewayConnectionConfig.Builder setSafeModeEnabled (boolean enabled)
```

Enable/disable safe mode

If a VCN fails to provide connectivity within a system-provided timeout, it will enter safe mode. In safe mode, the VCN Network will be torn down and the system will restore connectivity by allowing underlying cellular or WiFi networks to be used as default. At the same time, VCN will continue to retry until it succeeds.

When safe mode is disabled and VCN connection fails to provide connectivity, end users might not have connectivity, and may not have access to carrier-owned underlying networks.

<br />

|                                     Parameters                                      ||
|-----------|--------------------------------------------------------------------------|
| `enabled` | `boolean`: whether safe mode should be enabled. Defaults to`true` <br /> |

|                                                                               Returns                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | This value cannot be`null`. <br /> |

### setVcnUnderlyingNetworkPriorities

Added in[API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public VcnGatewayConnectionConfig.Builder setVcnUnderlyingNetworkPriorities (List<VcnUnderlyingNetworkTemplate> underlyingNetworkTemplates)
```

Set the list of templates to match underlying networks against, in high-to-low priority order.

To select the VCN underlying network, the VCN connection will go through all the network candidates and return a network matching the highest priority rule.

If multiple networks match the same rule, the VCN will prefer an already-selected network as opposed to a new/unselected network. However, if both are new/unselected networks, a network will be chosen arbitrarily amongst the networks matching the highest priority rule.

If all networks fail to match the rules provided, a carrier-owned underlying network will still be selected (if available, at random if necessary).

<br />

|                                                                                                                                                              Parameters                                                                                                                                                              ||
|------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `underlyingNetworkTemplates` | `List`: a list of unique VcnUnderlyingNetworkTemplates that are ordered from most to least preferred, or an empty list to use the default prioritization. The default network prioritization order is Opportunistic cellular, Carrier WiFi and then Macro cellular. This value cannot be`null`. <br /> |

|                                                                                                                                               Returns                                                                                                                                                ||
|----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [VcnGatewayConnectionConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder) | this[Builder](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig.Builder)instance, for chaining This value cannot be`null`. <br /> |