连接到集群数据库时出现 mongo 异常

时间:2021-05-28 12:16:05

标签: java spring mongodb spring-boot

所以我目前在我的 Spring Boot 项目中使用 <dep.spring.boot.data.mongodb.version>2.4.4</dep.spring.boot.data.mongodb.version>。在我的 yml 中,我有以下 mongo 配置:

spring:
  data:
    mongodb:
      uri: mongodb://dbuser:p@ssword@db1.com:40001,db2.com:40001/testDb?replicaSet=test1

连接到数据库时出现以下错误:

Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@66245572. Client view of cluster state is {type=REPLICA_SET, servers=[{address=db2.com:40001, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}, {address=db1.com:40001, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@66245572. Client view of cluster state is {type=REPLICA_SET, servers=[{address=db2.com:40001, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}, {address=db1.com:40001, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}]

我可以在 Robo3t 上使用字符串 uri 连接到数据库,所以我假设我需要在我的应用程序上放置额外的配置?

0 个答案:

没有答案
相关问题