nats.rs
nats.rs copied to clipboard
Connect coroutine can't terminate
Make sure that these boxes are checked before submitting your issue -- thank you!
- [0.24 ] Included below version and environment information
- [ ] Included a [Minimal, Complete, and Verifiable example] (https://stackoverflow.com/help/mcve)
NATS version (grep 'name = "nats"' Cargo.lock -A 1
)
rustc version (rustc --version
- we support Rust 1.41 and up)
OS/Container environment:
Steps or code to reproduce the issue:
connect coroutine will leak when retry_on_initial_connect is set and try connect to a wrong address
pub(crate) async fn connect(&mut self) -> Result<(ServerInfo, Connection), io::Error> {
loop {
match self.try_connect().await {
Ok(inner) => return Ok(inner),
Err(error) => {
self.events_tx
.send(Event::ClientError(ClientError::Other(error.to_string())))
.await
.ok();
}
}
}
}
Expected result:
get some ways to drop bad Client with wrong server address
Actual result:
if we set a wrong addrees,we can't drop the bad Client.
Hey,
thanks for the report.
https://github.com/nats-io/nats.rs/pull/692 should fix it, and when dropping Client, all tokio::task
s should be dropped too.