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

When I connect to azure-sql-edge on macos, there is no response for a long time and the connection does not end, and there is no error reported #375

Open
Schira4396 opened this issue Feb 20, 2025 · 0 comments

Comments

@Schira4396
Copy link

Code:

use tiberius::{Client, Config, AuthMethod, error::Error};
use tokio_util::compat::TokioAsyncWriteCompatExt;
use tokio::net::TcpStream;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut config = Config::new();

    config.host("172.16.4.228");
    config.port(1433);
    config.authentication(AuthMethod::sql_server("SA", "<Mys3cureP4ssW0rD>"));

    let tcp = TcpStream::connect(config.get_addr()).await?;
    tcp.set_nodelay(true)?;

    let client = match Client::connect(config, tcp.compat_write()).await {
        // Connection successful.
        Ok(client) => {
            client
        },
        // The server wants us to redirect to a different address
        Err(Error::Routing { host, port }) => {
            println!("Routing {} at host {} failed", host, port);
            let mut config = Config::new();

            config.host(&host);
            config.port(port);
            config.authentication(AuthMethod::sql_server("SA", "<Mys3cureP4ssW0rD>"));

            let tcp = TcpStream::connect(config.get_addr()).await?;
            tcp.set_nodelay(true)?;

            // we should not have more than one redirect, so we'll short-circuit here.
            Client::connect(config, tcp.compat_write()).await?
        }
        Err(e) => {
            println!("{:?}", e);
            Err(e)?
        },
    };

    Ok(())
}

My Cargo.toml:

tiberius={ version = "*", default-features = true}
tokio = { version = "*", features = ["full"] }
tokio-util = {version = "*", features = ["compat"]}

Oddly enough, when I set default-features to False, it works, and vice versa, and on windows, the code works even if default-features are True.

I do not understand why this is, is it because macos does not support the default feature TDS73 or native tls? I would appreciate an answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant