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
[dependencies.mongodb]
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(
"mongodb+srv://user:pass@atlas-host/test?w=majority",
)?;
// Ping the server to see if you can connect to the cluster
client
.database("admin")
.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);
}
Ok(())
}
Mongosh connects fine as do any tests with Ruby/Mongoid, Elixir or Swift.
Any thoughts as to what is wrong?