Pausing Between Reconnect Attempts

    This setting not only prevents wasting client resources, it also alleviates a thundering herd situation when additional servers are not available.

    Go

    1. server("nats://demo.nats.io:4222").
    2. reconnectWait(Duration.ofSeconds(10)). // Set Reconnect Wait
    3. build();
    4. Connection nc = Nats.connect(options);
    5. // Do something with the connection
    6. nc.close();

    JavaScript

    Python

    1. nc = NATS()
    2. await nc.connect(
    3. servers=["nats://demo.nats.io:4222"],
    4. reconnect_time_wait=10,
    5. )
    6. await nc.close()

    TypeScript

    1. // will throw an exception if connection fails
    2. let nc = await connect({
    3. servers: ["nats://demo.nats.io:4222"]
    4. nc.close();

    C