Redis-rs, ConnectionManager gives dangling connection

Greetings!

I have a problem with non-closing connection when use ConnectionManager. For example:

let mut redis = ConnectionManager::new(REDIS_CLIENT.clone()).await?;
<...>
let (tx, mut cancel) = mpsc::channel(1);
let task = tokio::task::spawn(async move {
    loop {
        let data = tokio::select! {
            data = redis.xread_options::<_, _, StreamReadReply>(mwi, &now, &opts) => data,
            _ = cancel.recv() => break,
        };
<...>
    }
});

When I send tx.send(()).await; , yeah, loop are breaking. But, future with redis.xread_options (from what I read) just suspends without releasing data. So, as a result, I got a dangling connection to Redis DB.
If xread get some data after abortion, connection will be closed.

P.S. Author of redis-rs doesn't answer: `tokio::select` with async ConnectionManager and channel for cancelation · Issue #553 · mitsuhiko/redis-rs · GitHub

I think I've seen a similar question before on this site. Unless you can find a way to explicitly kill the connection, there's nothing you can do besides waiting for the call to return.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.