-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async nats trying cluster connect #801
Comments
Hey!
You can either iterate over some collection and parse addresses, or pass slice directly. async fn addrs() -> Result<(), async_nats::Error> {
let servers = vec!["demo.nats.io", "other.nats.io"];
let client = async_nats::connect(
servers
.iter()
.map(|url| url.parse())
.collect::<Result<Vec<ServerAddr>, _>>()?
.as_slice(),
)
.await?;
or pass list directly: let client = async_nats::connect(
[
"demo.nats.io".parse::<ServerAddr>()?,
"other.nats.io".parse::<ServerAddr>()?,
]
.as_slice(),
)
.await
.unwrap();
Ok(())
} |
Added utility to pass |
Oh its work, thank you 🙂 |
Great! |
Hi! I trying connect to cluster and got the message
NATS server URL is invalid: invalid port number
env:
NATS_CLUSTER=nats://localhost:4222,nats://localhost:14222,nats://localhost:24222
Why its happening?
The text was updated successfully, but these errors were encountered: