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

Timeout when connecting to DB over VPN #360

Open
waywardcoder opened this issue Oct 7, 2024 · 1 comment
Open

Timeout when connecting to DB over VPN #360

waywardcoder opened this issue Oct 7, 2024 · 1 comment

Comments

@waywardcoder
Copy link

waywardcoder commented Oct 7, 2024

I have some code that uses bb8-tiberius and tiberius, everything works when i am inside the network where the server lives, but when connecting over VPN tiberius times out trying to create the connection. Other db tools like sqlcmd and azure data studio work. I added logging and set to TRACE, but can't see any reason why it would fail. Any assistance appreciated:

here is the code:

impl DbMigrationClient {
pub async fn new() -> DbMigrationClient {
#[cfg(feature = "gcp-secrets")]
let secrets_manager: Arc<dyn SecretManager + Send + Sync> =
Arc::new(GcpSecretManager::new().await);

    #[cfg(feature = "env-secrets")]
    let secrets_manager: Arc<dyn SecretManager + Send + Sync> =
        Arc::new(EnvSecretsManager::new().await);

    let connection_string = format!(
        "uid={2};password={3};database={1};server=tcp:{0};TrustServerCertificate=true;encrypt=true",
        secrets_manager.get_secret("SQLSERVER_NAME").await.unwrap_or_default(),
        secrets_manager.get_secret("SQLSERVER_DB").await.unwrap_or_default(), 
        secrets_manager.get_secret("SQLSERVER_USER").await.unwrap_or_default(), 
        secrets_manager.get_secret("SQLSERVER_PASSWORD").await.unwrap_or_default());



    println!("Connection String = {}", connection_string);
    let mgr = bb8_tiberius::ConnectionManager::build(connection_string.as_str()).unwrap();
    let pool = bb8::Pool::builder().max_size(12).build(mgr).await.unwrap();

    DbMigrationClient {
        client: welds::connections::mssql::connect(connection_string.as_str())
            .await
            .unwrap(),
    }
}

Here are the logs on trace

2024-10-07T18:16:58.435555Z TRACE shared::dal::dbclient: get_all_active_agents_in_state with_state="Illinois" with_status="1"

2024-10-07T18:16:58.514661Z TRACE tiberius::client::connection: Sending a packet (41 bytes)
2024-10-07T18:16:58.590501Z TRACE tiberius::tds::codec::decode: Reading a TabularResult (37 bytes)
2024-10-07T18:16:58.590640Z INFO tiberius::client::connection: Performing a TLS handshake
2024-10-07T18:16:58.590696Z WARN tiberius::client::tls_stream::native_tls_stream: Trusting the server certificate without validation.
thread 'main' panicked at /Code/pts_agency_migration/shared/src/dal/dbclient.rs:350:15:
called Result::unwrap() on an Err value: Database(Bb8("bb8 timeout"))
stack backtrace:
0: rust_begin_unwind
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
1: core::panicking::panic_fmt
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:74:14
2: core::result::unwrap_failed
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/result.rs:1679:5
3: core::result::Result<T,E>::unwrap
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/result.rs:1102:23
4: shared::dal::dbclient::DbMigrationClient::get_all_active_agents_in_state::{{closure}}
at ./shared/src/dal/dbclient.rs:350:9
5: shared::dal::dbclient::DbMigrationClient::get_all_agencies_ensuring_groups_present::{{closure}}
at ./shared/src/dal/dbclient.rs:247:76
6: agency_dump::dump_agent_list::{{closure}}
at ./agency_dump/src/main.rs:47:10
7: agency_dump::main::{{closure}}
at ./agency_dump/src/main.rs:32:84
8: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
at /Users/chrisdupuy-admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/park.rs:281:63
9: tokio::runtime::coop::with_budget
at /Users/chrisdupuy-admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:107:5
10: tokio::runtime::coop::budget
at /Users/chrisdupuy-admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/coop.rs:73:5
11: tokio::runtime::park::CachedParkThread::block_on
at /Users/chrisdupuy-admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/park.rs:281:31
12: tokio::runtime::context::blocking::BlockingRegionGuard::block_on
at /Users/chrisdupuy-admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/blocking.rs:66:9
13: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}
at /Users/chrisdupuy-admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
14: tokio::runtime::context::runtime::enter_runtime
at /Users/chrisdupuy-admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/context/runtime.rs:65:16
15: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
at /Users/chrisdupuy-admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
16: tokio::runtime::runtime::Runtime::block_on_inner
at /Users/chrisdupuy-admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/runtime.rs:363:45
17: tokio::runtime::runtime::Runtime::block_on
at /Users/chrisdupuy-admin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.40.0/src/runtime/runtime.rs:335:13
18: agency_dump::main
at ./agency_dump/src/main.rs:37:5
19: core::ops::function::FnOnce::call_once
at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

@waywardcoder
Copy link
Author

Taking BB8 out of it and using just tiberius, it doesn't seem to connect:

Error: Tls("connection closed via error")

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