mongodb副本集,不加权限校验的时候客户端连接是没有问题的,加上权限校验后,就报如下异常:
Caused by: com.mongodb.MongoException$Network: IOException authenticating the connection
at com.mongodb.DBPort$NativeAuthenticator.authenticate(DBPort.java:661)
at com.mongodb.DBPort.authenticate(DBPort.java:370)
at com.mongodb.DBPort.checkAuth(DBPort.java:381)
at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:299)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:279)
at com.mongodb.DBCollectionImpl.find(DBCollectionImpl.java:84)
at com.mongodb.DB.command(DB.java:317)
at com.mongodb.DB.command(DB.java:296)
at com.mongodb.DBCollection.getCount(DBCollection.java:1189)
at com.mongodb.DBCollection.getCount(DBCollection.java:1154)
at com.mongodb.DBCollection.getCount(DBCollection.java:1138)
at com.mongodb.DBCollection.getCount(DBCollection.java:1107)
at com.mongodb.DBCollection.getCount(DBCollection.java:1066)
at cn.sunline.ltts.base.ftp.TestDemo.test(TestDemo.java:90)
... 25 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:196)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at org.bson.io.Bits.readFully(Bits.java:48)
at org.bson.io.Bits.readFully(Bits.java:35)
at org.bson.io.Bits.readFully(Bits.java:30)
at com.mongodb.Response.<init>(Response.java:42)
at com.mongodb.DBPort$1.execute(DBPort.java:141)
at com.mongodb.DBPort$1.execute(DBPort.java:135)
at com.mongodb.DBPort.doOperation(DBPort.java:164)
at com.mongodb.DBPort.call(DBPort.java:135)
at com.mongodb.DBPort.findOne(DBPort.java:189)
at com.mongodb.DBPort.runCommand(DBPort.java:197)
at com.mongodb.DBPort$NativeAuthenticator.authenticate(DBPort.java:653)
... 38 more
mongodb服务端版本为:mongodb-linux-x86_64-rhel62-3.2.7
java客户端使用的版本为:mongo-java-driver-2.12.1.jar
我要上传文件导名为mongodb的库,在这个库中用户都建了,但是就是报错
这是客户端测试代码:
ServerAddress sa = new ServerAddress("172.18.50.113:27017");
ServerAddress sa1 = new ServerAddress("172.18.50.114:27017");
List<ServerAddress> sends = new ArrayList<ServerAddress>();
sends.add(sa);
sends.add(sa1);
List<MongoCredential> mongoCredentialList = new ArrayList<MongoCredential>();
mongoCredentialList.add(MongoCredential.createMongoCRCredential("common", "mongodb", "common".toCharArray()));
DB db = new MongoClient(sends, mongoCredentialList).getDB("mongodb");
DBCollection collection = db.getCollection("phfund_ds.datas");
System.out.println(collection.getCount());
请问有哪位大虾知道为什么吗?求赐教!
Credential的帐密是否对?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。