Table of Contents

Property RetryOnInitialConnect

Namespace
NATS.Client.Core
Assembly
NATS.Client.Core.dll

RetryOnInitialConnect

Determines whether the client should retry connecting to the server during the initial connection attempt if the connection fails. (default: false)

public bool RetryOnInitialConnect { get; init; }

Property Value

bool

Remarks

This property controls the behavior of the initial connection process.

When set to true, the client will periodically retry connecting to the server based on the configured retry intervals until a successful connection is established or the operation is explicitly canceled.

When set to false (default behavior), the client will not retry and will throw an exception if the connection cannot be established initially.

The retry intervals are influenced by options such as ReconnectWaitMin and ReconnectWaitMax, with the potential addition of ReconnectJitter for randomized delays between retries. This property is particularly useful in scenarios where transient network failures or server unavailability are expected during the first connection attempt.