如何解决在Micronaut中连接到AWS documentDB
我正在尝试将Micronaut应用程序连接到AWS DocumentDB上的MongoDB实例,这需要在连接字符串上设置某些参数(mongodb:// user:pass @ host:port /?ssl = true&ssl_ca_certs = rds-组合ca.bundle.pem&replicaSet = rs0&readPreference = secondaryPreferred&retryWrites = false)。
我查看了此文档https://micronaut-projects.github.io/micronaut-mongodb/1.0.4/guide/configurationreference.html,并决定尝试使用当前配置:
mongodb:
uri: "mongodb://${DB_USER:user}:${DB_PASS:pass}@${DB_HOST:host}:${DB_PORT:port}"
options:
ssl-enabled: true
read-preference: "secondaryPreferred"
required-replica-set-name: "rs0"
retry-writes: false
当我尝试从应该连接到该Mongo实例的服务中调用端点时,这会导致以下错误消息:
{
"message": "Internal Server Error: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN,servers=[{address=host:port,type=UNKNOWN,state=CONNECTING,exception={com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message},caused by {java.nio.channels.InterruptedByTimeoutException}}]"
}
这使我相信该配置未正确应用。另外,我应该在配置中添加SSL证书“ rds-combined-ca-bundle.pem”,但是没有找到与此相关的任何内容。
如何修复连接以使其正常工作?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。