从 Mule 连接到 Mongo Atlas 时出现身份验证错误 [英] Authentication error when connecting to Mongo Atlas from Mule
问题描述
我正在使用 Anypoint Studio 6.1 和 Mule 3.8.1,并且正在尝试配置我的 Anypoint Mongo Connector v4.1 以连接到 Mongo Atlas (mongodb v3.4).
I am using Anypoint Studio 6.1 and Mule 3.8.1 and am trying to configure my Anypoint Mongo Connector v4.1 to connect to Mongo Atlas (mongodb v3.4).
我可以通过 mongo shell 进行连接,但是当我向 mongo 连接器配置添加相同的详细信息时,我收到以下错误:
I can connect via the mongo shell but when I add the same details to the mongo connector configuration I get the following error:
org.mule.api.ConnectionException: Authentication failed
org.mule.api.ConnectionException: Authentication failed
at org.mule.modules.mongo.Config.testConnect(Config.java:190)
at org.mule.modules.mongo.generated.connectivity.ConfigMongoCloudConnectorAdapter.test(ConfigMongoCloudConnectorAdapter.java:27)
at org.mule.modules.mongo.generated.connectivity.MongoCloudConnectorConfigConnectionManagementConnectionManager.test(MongoCloudConnectorConfigConnectionManagementConnectionManager.java:442)
at org.mule.tooling.metadata.api.utils.ConnectionTester.internalTestConnection(ConnectionTester.java:88)
at org.mule.tooling.metadata.api.utils.ConnectionTester.testConnectionFor(ConnectionTester.java:113)
at org.mule.tooling.messageflow.action.TestConnectorConnectionFromMuleConfigAction$1$1$1$1.call(TestConnectorConnectionFromMuleConfigAction.java:68)
at org.mule.tooling.messageflow.action.TestConnectorConnectionFromMuleConfigAction$1$1$1$1.call(TestConnectorConnectionFromMuleConfigAction.java:1)
at org.mule.tooling.utils.SilentRunner.run(SilentRunner.java:25)
at org.mule.tooling.core.StudioDesignContextRunner.runSilentWithMuleProject(StudioDesignContextRunner.java:17)
at org.mule.tooling.core.StudioDesignContextRunner.runSilentWithMuleProject(StudioDesignContextRunner.java:37)
at org.mule.tooling.messageflow.action.TestConnectorConnectionFromMuleConfigAction$1$1$1.run(TestConnectorConnectionFromMuleConfigAction.java:65)
at java.lang.Thread.run(Unknown Source)
Caused by: com.mongodb.MongoTimeoutException: Timed out after 5000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=shard0.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='admin-user', source='mydatabase', password=<hidden>, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server shard0.mongodb.net:27017. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }}}, {address=shard1.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='admin-user', source='myDatabase', password=<hidden>, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server shard1.mongodb.net:27017. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }}}, {address=shard2.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=null, userName='admin-user', source='myDatabase', password=<hidden>, mechanismProperties={}}}, caused by {com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' on server shard2.mongodb.net:27017. The full response is { "ok" : 0.0, "errmsg" : "Authentication failed.", "code" : 18, "codeName" : "AuthenticationFailed" }}}]
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:369)
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71)
at com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:89)
at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:84)
at com.mongodb.operation.CommandReadOperation.execute(CommandReadOperation.java:55)
at com.mongodb.Mongo.execute(Mongo.java:773)
at com.mongodb.Mongo$2.execute(Mongo.java:760)
at com.mongodb.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:130)
at com.mongodb.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:124)
at com.mongodb.MongoDatabaseImpl.runCommand(MongoDatabaseImpl.java:114)
at org.mule.modules.mongo.api.MongoClientImpl.executeCommand(MongoClientImpl.java:321)
at org.mule.modules.mongo.api.MongoClientImpl.isAlive(MongoClientImpl.java:335)
at org.mule.modules.mongo.Config.testConnect(Config.java:183)
... 11 more
java.lang.Throwable: org.mule.api.ConnectionException: Authentication failed
at org.mule.modules.mongo.Config.testConnect(Config.java:190)
at org.mule.modules.mongo.generated.connectivity.ConfigMongoCloudConnectorAdapter.test(ConfigMongoCloudConnectorAdapter.java:27)
at org.mule.modules.mongo.generated.connectivity.MongoCloudConnectorConfigConnectionManagementConnectionManager.test(MongoCloudConnectorConfigConnectionManagementConnectionManager.java:442)
at org.mule.tooling.metadata.api.utils.ConnectionTester.internalTestConnection(ConnectionTester.java:88)
at org.mule.tooling.metadata.api.utils.ConnectionTester.testConnectionFor(ConnectionTester.java:113)
at org.mule.tooling.messageflow.action.TestConnectorConnectionFromMuleConfigAction$1$1$1$1.call(TestConnectorConnectionFromMuleConfigAction.java:68)
at org.mule.tooling.messageflow.action.TestConnectorConnectionFromMuleConfigAction$1$1$1$1.call(TestConnectorConnectionFromMuleConfigAction.java:1)
at org.mule.tooling.utils.SilentRunner.run(SilentRunner.java:25)
at org.mule.tooling.core.StudioDesignContextRunner.runSilentWithMuleProject(StudioDesignContextRunner.java:17)
at org.mule.tooling.core.StudioDesignContextRunner.runSilentWithMuleProject(StudioDesignContextRunner.java:37)
at org.mule.tooling.messageflow.action.TestConnectorConnectionFromMuleConfigAction$1$1$1.run(TestConnectorConnectionFromMuleConfigAction.java:65)
at java.lang.Thread.run(Unknown Source)
Mongo Mule 连接器配置(因上述错误而失败)
<mongo:config name="Mongo_DB__Configuration" username="admin-user" password="pass1234" database="myDatabase" host="shard0.mongodb.net:27017, shard1.mongodb.net:27017, shard2.mongodb.net:27017" doc:name="Mongo DB: Configuration" ssl="true"/>
Mongo Shell 连接字符串(有效)
mongo "mongodb://shard0.mongodb.net:27017,shard1.mongodb.net:27017,shard2.mongodb.net:27017/myDatabase?replicaSet=shard0" --ssl --username admin-user --password pass1234
谢谢
推荐答案
确保您在连接字符串中将 authenticationDB
声明为 admin
.您的日志输出中似乎缺少此内容.
Ensure that you are stating the authenticationDB
to be admin
in your connection string. This looks to be missing from your log output.
这篇关于从 Mule 连接到 Mongo Atlas 时出现身份验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!