1
我們正在評估無法連接到MongoDB雲(ATlas)
我們正嘗試從Java應用連接到MongoDB雲(Atlas)。但觀察例外。
配置:在Ubuntu機器上運行
- Java測試應用程序的MongoDB託管在雲的MongoDB(阿特拉斯,cloud.mongodb.com)
- DB配置爲分片羣集環境。
代碼
MongoURI uri = new MongoURI("mongodb://<USERNAME>:<PASSWORD>@<SERVERIP_1>,<SERVERIP_2>,<SERVERIP_3>/admin?replicaSet=EPCCAP-shard-0&ssl=true&authSource=admin");
SimpleMongoDbFactory dbF = new SimpleMongoDbFactory(uri);
DB db = dbF.getDb("capdb");
System.out.println(db.getCollectionNames());
堆棧跟蹤:
Stacktrace : -
Jan 20, 2017 8:37:02 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Cluster created with settings {hosts=[<SERVERIP_1>, <SERVERIP_2>, <SERVERIP_3>], mode=MULTIPLE, requiredClusterType=REPLICA_SET, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500, requiredReplicaSetName='EPCCAP-shard-0'}
Jan 20, 2017 8:37:02 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Adding discovered server <SERVERIP_1> to client view of cluster
Jan 20, 2017 8:37:02 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Adding discovered server <SERVERIP_1> to client view of cluster
Jan 20, 2017 8:37:02 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Adding discovered server <SERVERIP_1> to client view of cluster
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Jan 20, 2017 8:37:02 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=REPLICA_SET, connectionMode=MULTIPLE, all=[ServerDescription{address=<SERVERIP_1>, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=<SERVERIP_2>, type=UNKNOWN, state=CONNECTING}, ServerDescription{address=<SERVERIP_3>, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
Jan 20, 2017 8:37:03 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Exception in monitor thread while connecting to server <SERVERIP_1>:27017
com.mongodb.MongoSocketWriteException: Exception sending message
\t at com.mongodb.connection.InternalStreamConnection.translateWriteException(InternalStreamConnection.java:462)
\t at com.mongodb.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:205)
\t at com.mongodb.connection.CommandHelper.sendMessage(CommandHelper.java:89)
\t at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32)
\t at com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:83)
\t at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:43)
\t at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115)
\t at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128)
\t at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address <RESOLVED_IP_ADDRESSED_MASKED> found
\t at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
\t at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
\t at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
\t at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
\t at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1497)
\t at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:212)
\t at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
\t at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
\t at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
\t at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
\t at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
\t at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
\t at com.mongodb.connection.SocketStream.write(SocketStream.java:75)
\t at com.mongodb.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:201)
\t ... 7 more
Caused by: java.security.cert.CertificateException: No subject alternative names matching IP address <RESOLVED_IP_ADDRESSED_MASKED> found
\t at sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:167)
\t at sun.security.util.HostnameChecker.match(HostnameChecker.java:93)
\t at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)
\t at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436)
\t at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200)
\t at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
\t at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1479)
\t ... 16 more
Jan 20, 2017 8:37:03 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Exception in monitor thread while connecting to server <SERVERIP_1>
com.mongodb.MongoSocketWriteException: Exception sending message
\t at com.mongodb.connection.InternalStreamConnection.translateWriteException(InternalStreamConnection.java:462)
\t at com.mongodb.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:205)
\t at com.mongodb.connection.CommandHelper.sendMessage(CommandHelper.java:89)
\t at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32)
\t at com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:83)
\t at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:43)
\t at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115)
\t at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128)
\t at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address <RESOLVED_IP_ADDRESSED_MASKED> found
\t at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
\t at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
\t at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
\t at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
\t at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1497)
\t at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:212)
\t at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
\t at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
\t at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
\t at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
\t at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
\t at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
\t at com.mongodb.connection.SocketStream.write(SocketStream.java:75)
\t at com.mongodb.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:201)
\t ... 7 more
Caused by: java.security.cert.CertificateException: No subject alternative names matching IP address <RESOLVED_IP_ADDRESSED_MASKED> found
\t at sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:167)
\t at sun.security.util.HostnameChecker.match(HostnameChecker.java:93)
\t at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)
\t at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436)
\t at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200)
\t at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
\t at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1479)
\t ... 16 more
Jan 20, 2017 8:37:03 PM com.mongodb.diagnostics.logging.JULLogger log
INFO: Exception in monitor thread while connecting to server <SERVERIP_1>
com.mongodb.MongoSocketWriteException: Exception sending message
\t at com.mongodb.connection.InternalStreamConnection.translateWriteException(InternalStreamConnection.java:462)
\t at com.mongodb.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:205)
\t at com.mongodb.connection.CommandHelper.sendMessage(CommandHelper.java:89)
\t at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32)
\t at com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:83)
\t at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:43)
\t at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:115)
\t at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:128)
\t at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address <RESOLVED_IP_ADDRESSED_MASKED> found
\t at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
\t at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
\t at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
\t at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:296)
\t at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1497)
\t at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:212)
\t at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
\t at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
\t at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
\t at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
\t at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
\t at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
\t at com.mongodb.connection.SocketStream.write(SocketStream.java:75)
\t at com.mongodb.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:201)
\t ... 7 more
Caused by: java.security.cert.CertificateException: No subject alternative names matching IP address <RESOLVED_IP_ADDRESSED_MASKED> found
\t at sun.security.util.HostnameChecker.matchIP(HostnameChecker.java:167)
\t at sun.security.util.HostnameChecker.match(HostnameChecker.java:93)
\t at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455)
\t at sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:436)
\t at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:200)
\t at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
\t at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1479)
\t ... 16 more