nats.rs icon indicating copy to clipboard operation
nats.rs copied to clipboard

expose retry_on_failed_connect option

Open cn-kali-team opened this issue 3 months ago • 3 comments

  • Expose retry_on_failed_connect option
  • Debug error field
    #[tokio::main]
    async fn main() -> Result<(), async_nats::Error> {
      async_nats::ConnectOptions::new()
         .retry_on_failed_connect()
         .connect("demo.nats.io")?;
     Ok(())
    }

cn-kali-team avatar Mar 20 '24 01:03 cn-kali-team

It looks like retry_on_initial_connect is already doing what you're looking for and retry_on_failed_connect is just dead code

paolobarbolini avatar Mar 20 '24 13:03 paolobarbolini

Oh, maybe this is the old code in syncing NATS. I can't reconnect in the consumer, but can I reconnect by switching to stream?

cn-kali-team avatar Mar 20 '24 14:03 cn-kali-team

The reconnect happens automatically in the client. You check the events on connection to see what's the state of connection. The retry_on_initial_connect is for the client to retry connecting if initial connection failed. Reconnecting afterwards will happen reagardless this option value.

Jarema avatar Mar 22 '24 11:03 Jarema