I’ve been trying to run a very simple program, to test out mongo with rust. However, I can’t seem to connect at all
I keep getting DnsResolve { message: "No connections available" }
My coworkers, running the exact same code are getting no errors. So it must be a problem on my side but there is no documentation or info anywhere to help me find out what this problem could be.
Here is the code, with credentials obstructed obv
use mongodb::{bson::doc, options::ClientOptions, Client};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let uri = "mongodb+srv://<uname>:<pw>@cluster0.cugioru.mongodb.net/?retryWrites=true&w=majority";
let mut client_options = ClientOptions::parse(uri).await.unwrap();
client_options.app_name = Some("My App".to_string());
ERROR HERE >>> let client: Client = Client::with_options(client_options).unwrap();
let mut client_options = ClientOptions::parse(uri).await.unwrap();
... Do stuff with client
Ok(())
}
I’m not too familiar with rust but based off the error, it might be related to the DNS resolution of the SRV record. Are your co-workers connecting to the cluster using a different network?
Could you also try the following from the same client and advise the output?
I do agree with your assessment here regarding the issue being specific to the problem machine. In saying so, it doesn’t appear that this is a MongoDB related issue. Unfortunately I am not too familiar with the environment you have specified below and how to troubleshoot DNS issues here:
Generally the Google DNS servers are able to resolve the Atlas DNS SRV records - I am not sure of the steps of how to force your machine to use this DNS but is it something you have tried from a troubleshooting perspective?