Disabling Reconnect

    Go

    1. server("nats://demo.nats.io:4222").
    2. noReconnect(). // Disable reconnect attempts
    3. build();
    4. Connection nc = Nats.connect(options);
    5. // Do something with the connection

    JavaScript

    1. await nc.connect(
    2. servers=[
    3. "nats://demo.nats.io:1222",
    4. "nats://demo.nats.io:1223",
    5. "nats://demo.nats.io:1224"
    6. ],
    7. allow_reconnect=False,
    8. # Do something with the connection
    9. await nc.close()

    Ruby

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

    C