简体   繁体   English

从Mule连接到Mongo Atlas时出现身份验证错误

[英]Authentication error when connecting to Mongo Atlas from Mule

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). 我正在使用Anypoint Studio 6.1和Mule 3.8.1,并试图将我的Anypoint Mongo Connector v4.1配置为连接到Mongo Atlas(mongodb v3.4)。

I can connect via the mongo shell but when I add the same details to the mongo connector configuration I get the following error: 我可以通过mongo shell进行连接,但是当我在mongo连接器配置中添加相同的详细信息时,会出现以下错误:

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 Connector Config (Fails with error above) 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 Connection String (works) 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

Thanks 谢谢

Ensure that you are stating the authenticationDB to be admin in your connection string. 确保您在连接字符串中声明authenticationDBadmin This looks to be missing from your log output. 您的日志输出中似乎缺少此内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM