You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Code:
My Cargo.toml:
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.
The text was updated successfully, but these errors were encountered: