0

I’m trying to connect to AWS DocumentDB server using the Rust driver with MONGODB-AWS ($external) authentication. A simple “list collections” call fails during the initial handshake with:

Command isMaster not supported on $external database

Following code:

use std::path::PathBuf;
use mongodb::Client;
use mongodb::options::{AuthMechanism, ClientOptions, Credential, Tls, TlsOptions};

#[tokio::main]
async fn main() {
    let uri = "mongodb://localhost:27017/tpch?directConnection=true";

    let mut opts = ClientOptions::parse(uri).await.unwrap();

    opts.credential = Some(
        Credential::builder()
            .username("<access_key>".to_string())
            .password("<secret_access_key>".to_string())
            .source("$external".to_string())
            .mechanism(AuthMechanism::MongoDbAws)
            .build()
    );

    let ca_path = PathBuf::from("/Users/krinart/global-bundle.pem");
    opts.tls = Some(Tls::Enabled(
        TlsOptions::builder()
            .ca_file_path(Some(ca_path))
            .allow_invalid_hostnames(true)
            .build(),
    ));

    let client = Client::with_options(opts).unwrap();

    let db = client.database("tpch");
    println!("Collections: {:?}", db.list_collection_names().await.unwrap());
}

Returns:

Error { kind: Command(CommandError { code: 73, code_name: "", message: "Command isMaster not supported on $external database.", topology_version: None }), labels: {}, wire_version: None, source: None }

For the context this command works:

AWS_ACCESS_KEY_ID=<> AWS_SECRET_ACCESS_KEY=<> mongosh \
  --host localhost \
  --port 27017 \
  --tls \
  --tlsCAFile /Users/krinart/global-bundle.pem \
  --tlsAllowInvalidHostnames \
  --authenticationDatabase '$external' \
  --authenticationMechanism MONGODB-AWS \
  tpch

1 Answer 1

0

This is because DocumentDB does not support isMaster; it utilizes hello instead, particularly in newer releases (v5.0). Ensure your driver version is compatible and uses hello, or upgrade the cluster to v5.0 for better API alignment with MongoDB

Sign up to request clarification or add additional context in comments.

1 Comment

I use DocumentDB 5.0.0 and I get the same issue with hello.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.