Skip to content
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

bug: async_nats::connect ignores all options in nats url #1341

Open
haruki-nikaidou opened this issue Nov 10, 2024 · 1 comment
Open

bug: async_nats::connect ignores all options in nats url #1341

haruki-nikaidou opened this issue Nov 10, 2024 · 1 comment
Labels
defect Suspected defect such as a bug or regression

Comments

@haruki-nikaidou
Copy link

Observed behavior

async_nats::connect ignores all options in nats url and use default options

Expected behavior

parse options from url

Server and client version

bug is in crate async-nats 0.37.0

Host environment

No response

Steps to reproduce

The bug is very obvious in the source code:

in lib.rs L1113

pub async fn connect<A: ToServerAddrs>(addrs: A) -> Result<Client, ConnectError> {
    connect_with_options(addrs, ConnectOptions::default()).await
}

And according to lib.rs L932~L1022, connect_with_options use option in argument to override the options in url. So connect ignore all options in url.

reproduce:

#[cfg(test)]
mod test {
    #[tokio::test]
    async fn test_nats_url_parse() {
        const URL: &str = "nats://yourusername:[email protected]:4222";
        let _ = async_nats::connect(URL).await.unwrap();  
    }
}
@haruki-nikaidou haruki-nikaidou added the defect Suspected defect such as a bug or regression label Nov 10, 2024
@Jarema
Copy link
Member

Jarema commented Nov 11, 2024

Thanks for reporting.

This is true, however I would advise using ConnectOptions for setting up credentials - especially if you pass in multiple servers.

There is also #1193 that would need to be fix for that to work.

This can be of course fixed, but is a pretty low priority considering not being the most optimal way to pass credentials to the client.

Are you maybe interested in contributing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

2 participants