Skip to content

Failed to resolve dns with mongo+srv & ssl=false #1638

@harveysnsoft

Description

@harveysnsoft

Versions/Environment

  1. What version of Rust are you using?
    v1.94.0

  2. What operating system are you using?
    macOS 26.2

  3. What versions of the driver and its dependencies are you using? (Run
    cargo pkgid mongodb & cargo pkgid bson)
    registry+https://github.com/rust-lang/crates.io-index#mongodb@3.5.1
    registry+https://github.com/rust-lang/crates.io-index#bson@2.15.0

  4. What version of MongoDB are you using? (Check with the MongoDB shell using db.version())
    MongoDB 8.0.16 Community

  5. What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)?
    Replica Set

Describe the bug

We are using managed mongodb service from Aliyun. When we try to connect using mongo+srv with ssl=false, the dns-resolver doesnt seem to be able to resolve it. But the exact same uri works in MongoDB Compass & nodejs mongo driver. I am curious if rust driver requires +srv to work with ssl=true only?

If I switch to use mongo:// + multipls hosts. It is working as expected.

To Reproduce

  1. Connect DB
let uri = "mongodb+srv://xxx:yyy@zzz.mongodb.singapore.nosql.aliyuncs.com/testdb?ssl=false&retryWrites=true&w=majority&readPreference=secondaryPreferred"
let client = Client::with_uri_str(uri)
            .await
            .map_err(|e| DomainError::DatabaseError(e.to_string()))?;
  1. cargo run

  2. Error
    Error: DatabaseError("Kind: An error occurred during DNS resolution: proto error: request timed out, labels: {}, source: None, server response: None")

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions