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
server("nats://demo.nats.io:4222").
reconnectWait(Duration.ofSeconds(10)). // Set Reconnect Wait
build();
Connection nc = Nats.connect(options);
// Do something with the connection
nc.close();
JavaScript
Python
nc = NATS()
await nc.connect(
servers=["nats://demo.nats.io:4222"],
reconnect_time_wait=10,
)
await nc.close()
TypeScript
// will throw an exception if connection fails
let nc = await connect({
servers: ["nats://demo.nats.io:4222"]
nc.close();
C