Spring com.mongodb.async.client.ClientSessionHelpe未从群集描述ClusterDescription中选择服务器
我正在尝试使用异步mongoClient连接到aws DocumentDB 我在aws中创建了DocumentDB集群,并通过ssh命令行成功连接 我过去创建了MongoClient和success连接并插入事件 但当我尝试创建com.mongodb.async.client.MongoClient时,连接失败,出现以下错误: WritableServerSelector未从群集描述中选择服务器 ClusterDescription{type=REPLICA\u SET,connectionMode=MULTIPLE, serverDescriptions=[ServerDescription{address=aws群集:27017, 类型=未知,状态=正在连接, 异常={com.mongodb.mongoscocketreadTimeoutException:超时 正在接收消息},原因是 {io.netty.handler.timeout.ReadTimeoutException}]}。等待30000 ms,然后超时Spring com.mongodb.async.client.ClientSessionHelpe未从群集描述ClusterDescription中选择服务器,spring,aws-documentdb,Spring,Aws Documentdb,我正在尝试使用异步mongoClient连接到aws DocumentDB 我在aws中创建了DocumentDB集群,并通过ssh命令行成功连接 我过去创建了MongoClient和success连接并插入事件 但当我尝试创建com.mongodb.async.client.MongoClient时,连接失败,出现以下错误: WritableServerSelector未从群集描述中选择服务器 ClusterDescription{type=REPLICA\u SET,connectionMo
ClusterSettings ClusterSettings=ClusterSettings.builder()
.applyConnectionString(新连接字符串(ConnectionString)).build();
列表凭据=新建ArrayList();
凭据。添加(
MongoCredential.createCredential(
mongoUserName,
mongoDBName,
蒙哥帕斯词);
MongoClientSettings=MongoClientSettings.builder()
.认证师(证书)
.clusterSettings(clusterSettings)
.streamFactoryFactory(新的NetyStreamFactoryFactory())
.writeConcern(writeConcern.conferenced)
.build();
com.mongodb.async.client.MongoClient MongoClient=MongoClients.create(设置);
MongoDatabase testDB=mongoClient.getDatabase(“myDB”);
MongoCollection collection=testDB.getCollection(“测试”);
文档文档=新文档(“名称”、“MongoDB”)。追加(“类型”、“数据库”);
//**正在尝试插入文档=>这里出现了一个错误**
collection.insertOne(doc,newsingleresultcallback(){
@凌驾
公开作废结果(最终作废结果、最终可丢弃结果){
System.out.println(“插入!”);
}
});
你有什么想法吗,为什么会发生这种情况?我遇到了一个类似的错误,对我来说,它与TLS配置有关
我在documentDB中禁用了TLS,我使用uri解决了它:
String uri = "mongodb://<username>:<Password>@<hostname>:27017/?ssl=true&ssl_ca_certs=cert";
MongoClientSettings settings = MongoClientSettings.builder()
.streamFactoryFactory(new NettyStreamFactoryFactory())
.applyConnectionString(new ConnectionString(uri))
.build();
com.mongodb.async.client.MongoClient mongoClient = MongoClients.create(settings);
String uri=“mongodb://:@:27017/?ssl=true&ssl\u ca\u certs=cert”;
MongoClientSettings=MongoClientSettings.builder()
.streamFactoryFactory(新的NetyStreamFactoryFactory())
.applyConnectionString(新连接字符串(uri))
.build();
com.mongodb.async.client.MongoClient MongoClient=MongoClients.create(设置);
有什么解决方案吗?
String uri = "mongodb://<username>:<Password>@<hostname>:27017/?ssl=true&ssl_ca_certs=cert";
MongoClientSettings settings = MongoClientSettings.builder()
.streamFactoryFactory(new NettyStreamFactoryFactory())
.applyConnectionString(new ConnectionString(uri))
.build();
com.mongodb.async.client.MongoClient mongoClient = MongoClients.create(settings);