Skip to content

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

@Schira4396

Description

@Schira4396

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions