Pausing Between Reconnect Attempts
// Set reconnect interval to 10 seconds
nc, err := nats.Connect("demo.nats.io", nats.ReconnectWait(10*time.Second))
if err != nil {
log.Fatal(err)
}
defer nc.Close()
// Do something with the connectionOptions options = new Options.Builder()
.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();const nc = await connect({
reconnectTimeWait: 10 * 1000, // 10s
servers: ["demo.nats.io"],
});Last updated
Was this helpful?