Handshake error connecting to host, v 2.0.0-beta.3

I have a variety of hosts. The ones that I’ve just tested this on are running Ubuntu 18.04 and 20.04. Both are reporting a handshake error when trying to connect to Atlas. I’m using the exact sync demo code posted to the respository, which I’ll copy here too.

The error:

Error: Error { kind: ServerSelection { message: “Server selection timeout: No available servers. Topology: { Type: ReplicaSetNoPrimary, Servers: [ { Address: atlas-hostname:27017, Type: Unknown, Error: tls handshake eof }, { Address: atlas-hostname:27017, Type: Unknown, Error: tls handshake eof }, { Address: atlas-hostname:27017, Type: Unknown, Error: tls handshake eof }, ] }” }, labels: {} }

My Cargo.toml:

name = "mongotest"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

version = "2.0.0-beta.3"
default-features = false
features = ["sync"]

And my actual code:

fn main() -> mongodb::error::Result<()> {
    // Get a handle to the cluster
    let client = Client::with_uri_str(
    // Ping the server to see if you can connect to the cluster
        .run_command(doc! {"ping": 1}, None)?;
    println!("Connected successfully.");
    // List the names of the databases in that cluster
    for db_name in client.list_database_names(None, None)? {
        println!("{}", db_name);

Mongosh connects fine as do any tests with Ruby/Mongoid, Elixir or Swift.

Any thoughts as to what is wrong?

1 Like

Hi @Mark_Windrim! It’s possible you’re running into RUST-272 if your instance size is > M2 and running MongoDB < 4.2. This issue is due to the fact that MongoDB < 4.2 running on Atlas servers currently uses a different set of TLS ciphers than rustls (the TLS library the driver uses under the hood) supports. This can be worked around by upgrading your MongoDB version to 4.2 (which supports the newer ciphers) or by downgrading your instance size, if those are options available to you. Sorry for any inconvenience this may cause!


Hi Patrick,

You hit the nail on the head. My instance is a M60 running on MongoDB 4.0.26. We’re working on updating some of our tools to work with v 4.4, which is the hangup on my side.

This would be a good note to add to your driver page. Would’ve saved me some time.


1 Like

We currently do have a brief note about it in the driver’s README, but the visibility and detail of that is not great and definitely could be improved. We’ll work on getting some information about this issue on the https://docs.mongodb.com/drivers/rust/ page as well to help with that. Thanks for the feedback!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.