{"record":{"id":"a2ac0cfa17e58614","repo":"risingwavelabs/risingwave","slug":"failed-to-send-hello-command-to-mongodb","errorCode":null,"errorMessage":"failed to send hello command to mongodb","messagePattern":"failed to send hello command to mongodb","errorType":"exception","errorClass":"SinkError::Mongodb","httpStatus":null,"severity":"error","filePath":"src/connector/src/sink/mongodb.rs","lineNumber":328,"sourceCode":"            }\n        }\n\n        if let Err(err) = self.config.common.collection_name.parse::<Namespace>() {\n            return Err(SinkError::Config(anyhow!(err).context(format!(\n                \"invalid collection.name {}\",\n                self.config.common.collection_name\n            ))));\n        }\n\n        // checking reachability\n        let client = self.config.common.build_client().await?;\n        let client = ClientGuard::new(self.param.sink_name.clone(), client);\n        client\n            .database(\"admin\")\n            .run_command(doc! {\"hello\":1})\n            .await\n            .map_err(|err| {\n                SinkError::Mongodb(anyhow!(err).context(\"failed to send hello command to mongodb\"))\n            })?;\n\n        if self.config.drop_collection_name_field && self.config.collection_name_field.is_none() {\n            return Err(SinkError::Config(anyhow!(\n                \"collection.name.field must be specified when collection.name.field.drop is enabled\"\n            )));\n        }\n\n        // checking dynamic collection name settings\n        if let Some(coll_field) = &self.config.collection_name_field {\n            let fields = self.schema.fields();\n\n            let coll_field_index = fields\n                .iter()\n                .enumerate()\n                .find_map(|(index, field)| {\n                    if &field.name == coll_field {\n                        Some(index)","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/sink/mongodb.rs#L310-L346","documentation":"During `validate`, the sink sends a `hello` command to the `admin` database to verify the MongoDB server is reachable before the sink starts. If the command fails (connection error, auth failure, DNS failure), the error is wrapped with this context. It fails sink creation early rather than failing later at write time.","triggerScenarios":"Creating a mongodb sink when the server URL is wrong, the cluster is down, network/firewall blocks the port, TLS fails, or credentials are invalid (auth errors surface on the first command).","commonSituations":"Typo in `mongodb://` URL or wrong port; RisingWave cannot reach a VPC/internal Mongo cluster; Atlas requires IP allowlisting; expired/rotated credentials.","solutions":["Verify the `url` option points to a reachable MongoDB instance (test with `mongosh <url>` from the same host/network as RisingWave).","Check network/firewall/allowlist rules (e.g., Atlas IP access list, VPC peering, security groups).","Confirm credentials in the URL are current and URL-encoded; check the wrapped mongodb error for the specific cause.","If using SRV (`mongodb+srv://`), ensure DNS SRV resolution works from the RisingWave host."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Reachability precheck from the same network as RisingWave\nconst { MongoClient } = require('mongodb');\nconst c = new MongoClient(url, { serverSelectionTimeoutMS: 5000 });\nawait c.db('admin').command({ hello: 1 }); await c.close();","typeGuard":null,"tryCatchPattern":"try {\n  await createMongodbSink(options);\n} catch (e) {\n  if (String(e).includes(\"failed to send hello command to mongodb\")) {\n    // inspect cause: DNS, auth, timeout — fix url/credentials/firewall\n  }\n  throw e;\n}","preventionTips":["Test the URL with mongosh from the RisingWave host","Keep the MongoDB cluster in Atlas IP allowlist / VPC peering","URL-encode credentials and rotate them carefully","Use short serverSelectionTimeout in prechecks"],"tags":["mongodb","network","connectivity","sink"],"backgroundTag":"connection-refused","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}