Rust driver 2.0.0 problems when ssl=true and tls=true

I use rust mongo driver 2.0.0, and I got problems when ssl=true and tls=true:

 Error: An error occurred during DNS resolution: InvalidDNSNameError

if ssl=false and tls=false, got this:

unexpected end of file

the uri string is:
mongodb://:@:27017/db_name?authSource=admin

this works fine at NodeJS.

the uri string is:
mongodb://username:pwd@ip:27017/db_name?authSource=admin

With ssl=false, RUST_BACKTRACE=full, this the logs:

Error: Server selection timeout: No available servers. Topology: { Type: Unknown, Servers: [ { Address: ***:27017, Type: Unknown, Error: unexpected end of file }, ] }
thread 'controller::game_service::test_super::test_game_update_one' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/test/src/lib.rs:194:5
stack backtrace:
   0:     0x5652bdaafbd0 - std::backtrace_rs::backtrace::libunwind::trace::ha0ad43e8a952bfe7
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x5652bdaafbd0 - std::backtrace_rs::backtrace::trace_unsynchronized::h6830419c0c4130dc
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5652bdaafbd0 - std::sys_common::backtrace::_print_fmt::h8f3516631ffa1ef5
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x5652bdaafbd0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he1640d5f0d93f618
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x5652bdad598c - core::fmt::write::h88012e1f01caeebf
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/fmt/mod.rs:1115:17
   5:     0x5652bdaa8b25 - std::io::Write::write_fmt::h7728c39ea5632753
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/io/mod.rs:1665:15
   6:     0x5652bdab1f1b - std::sys_common::backtrace::_print::ha1f00492f406a015
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x5652bdab1f1b - std::sys_common::backtrace::print::hd54561b13feb6af3
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x5652bdab1f1b - std::panicking::default_hook::{{closure}}::h84fe124cd0864662
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:208:50
   9:     0x5652bdab1a2c - std::panicking::default_hook::h5a8e74a76ce290a7
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:222:9
  10:     0x5652bdab25e4 - std::panicking::rust_panic_with_hook::h67c812a4fe9d4c91
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:622:17
  11:     0x5652bdab20c7 - std::panicking::begin_panic_handler::{{closure}}::h33f9c1b96af300d7
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:519:13
  12:     0x5652bdab00cc - std::sys_common::backtrace::__rust_end_short_backtrace::h51bae64be5921f0e
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:141:18
  13:     0x5652bdab2029 - rust_begin_unwind
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
  14:     0x5652bc52cdc1 - core::panicking::panic_fmt::h12a3a3c256485fca
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
  15:     0x5652bdad406e - core::panicking::assert_failed_inner::hd10540743cd0e11a
  16:     0x5652bda80b1a - core::panicking::assert_failed::h5c3efd64b01ea4b7
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:117:5
  17:     0x5652bc7facc1 - test::assert_test_result::h1eea97f876779783
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/test/src/lib.rs:194:5
  18:     0x5652bc564a9d - manager::controller::game_service::test_super::test_game_update_one::{{closure}}::hafab44beff96efa3
                               at /home/gitlab-runner/builds/141526a3/0/zoo/server_mgr_rs/src/controller/game_service.rs:378:11
  19:     0x5652bc884a4e - core::ops::function::FnOnce::call_once::h37b4a4df41b75102
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
  20:     0x5652bcbbfe13 - core::ops::function::FnOnce::call_once::h5aba9a5d361d6c79
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
  21:     0x5652bcbbfe13 - test::__rust_begin_short_backtrace::h705bb53b2b1d45e6
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/test/src/lib.rs:578:5
  22:     0x5652bcbbe8c8 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha20f614d7c0b2b6d
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/alloc/src/boxed.rs:1572:9
  23:     0x5652bcbbe8c8 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hf02f19eeb64ceabd
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panic.rs:347:9
  24:     0x5652bcbbe8c8 - std::panicking::try::do_call::h4bfab65eb3b4b036
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:401:40
  25:     0x5652bcbbe8c8 - std::panicking::try::h6613a46a6d2b6f88
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:365:19
  26:     0x5652bcbbe8c8 - std::panic::catch_unwind::h9f07b17b60991273
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panic.rs:434:14
  27:     0x5652bcbbe8c8 - test::run_test_in_process::hc38797eecf07854f
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/test/src/lib.rs:601:18
  28:     0x5652bcbbe8c8 - test::run_test::run_test_inner::{{closure}}::hac209db8bce0fd77
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/test/src/lib.rs:493:39
  29:     0x5652bcb8d05d - test::run_test::run_test_inner::{{closure}}::h4aefdd4b4a423e20
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/test/src/lib.rs:520:37
  30:     0x5652bcb8d05d - std::sys_common::backtrace::__rust_begin_short_backtrace::h652c9e2663704700
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys_common/backtrace.rs:125:18
  31:     0x5652bcb91838 - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::hd84fd5e0b5b1f45f
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/mod.rs:476:17
  32:     0x5652bcb91838 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::he23556962a2ae14b
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panic.rs:347:9
  33:     0x5652bcb91838 - std::panicking::try::do_call::h67d4f93e1fbaa5f9
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:401:40
  34:     0x5652bcb91838 - std::panicking::try::h396886e678db815e
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:365:19
  35:     0x5652bcb91838 - std::panic::catch_unwind::hc1d64dcecf0a00e0
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panic.rs:434:14
  36:     0x5652bcb91838 - std::thread::Builder::spawn_unchecked::{{closure}}::hc2644cf33cb61d8e
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/thread/mod.rs:475:30
  37:     0x5652bcb91838 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h4473c2c77b66963f
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/ops/function.rs:227:5
  38:     0x5652bdab84d7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6bff7798948b1075
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/alloc/src/boxed.rs:1572:9
  39:     0x5652bdab84d7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc2d25ac38f6b2342
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/alloc/src/boxed.rs:1572:9
  40:     0x5652bdab84d7 - std::sys::unix::thread::Thread::new::thread_start::hbba5bc368baac205
                               at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/sys/unix/thread.rs:74:17
  41:     0x7f572bb92e65 - start_thread
  42:     0x7f572b3b588d - clone
  43:                0x0 - <unknown>


The codes work find in my MacOS and 127.0.0.1 mongodb. But error at Centos7 and an online mongodb, which work find in nodejs and mongo-client.

This is the ClientOptions:

ClientOptions { hosts: [Tcp { host: “", port: Some(27017) }], app_name: Some(“game_conf”), compressors: None, connect_timeout: None, credential: Some(Credential(“REDACTED”)), direct_connection: None, driver_info: None, heartbeat_freq: None, local_threshold: None, max_idle_time: None, max_pool_size: None, min_pool_size: Some(5), read_concern: None, repl_set_name: None, retry_reads: None, retry_writes: None, selection_criteria: None, server_api: None, server_selection_timeout: None, socket_timeout: None, tls: Some(Disabled), write_concern: None, zlib_compression: None, original_srv_info: None, original_uri: Some("mongodb://:@*:27017/gamesLog?authSource=admin&tls=false”), resolver_config: None, allow_load_balanced: false, load_balanced: None }

Finally , this is a compatibility issue. My MongoDB is 3.2.x. However, in the driver’s compatibility table. it shows it only supports MongoDB 3.6.

Hi @GOVO_li, you are correct that the Rust driver only supports MongoDB 3.6 and up and this is the cause of the error you’re seeing.

1 Like