johnlpage / POCDriver

Workload Driver for MongoDB in Java
Other
204 stars 87 forks source link

Problems using MongoDB Atlas with POCDriver #30

Closed rbohan closed 5 years ago

rbohan commented 5 years ago

I'm attempting to run the POCDriver against an Atlas cluster as follows:

java -jar bin/POCDriver.jar -c "mongodb://user:password@host0.mongodb.net:27017,host1.mongodb.net:27017,host2.mongodb.net:27017/?ssl=true&replicaSet=rs0" -e

(valid credentials were replaced with anonymised data above)

Unfortunately I'm getting an error:

Exception in thread "main" com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ... Client view of cluster state is {type=REPLICA_SET, servers=[{address=...mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address ... found}, caused by {java.security.cert.CertificateException: No subject alternative names matching IP address ... found}}, {address=...mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address ... found}, caused by {java.security.cert.CertificateException: No subject alternative names matching IP address ... found}}, {address=...mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names matching IP address ... found}, caused by {java.security.cert.CertificateException: No subject alternative names matching IP address ... found}}]

This looks like an SSL issue but unsure what's going on. I'm using the latest version of the POCDriver and there is an ssl option supplied in the connection string...

Is this a bug?

Note I've also tried other options such as the srv connection string variant, reverting back to an older .jar file, etc - but getting nowhere.

If this is just a user error, is it possible to update the README with an example of how to successfully connect to Atlas?

Thanks!

jyemin commented 5 years ago

Hi @rbohan, what version of java are you using to run this (java -version)?

rbohan commented 5 years ago

Thanks @jyemin - that was it.

I'm running on macOS and the (default?) java binary reports:

$ java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

This binary lives in /usr/bin and is a symlink:

$ ls -ld `which java`
lrwxr-xr-x  1 root  wheel  74 14 Nov 22:41 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

Installing java from the Oracle website installs a new binary in this folder:

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

The current version info I have for that is as follows:

$ "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java" -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

Using that binary the POCDriver connects successfully to my Atlas cluster.

Thanks again!

(Now I just need to figure out why /usr/bin/java wasn't updated when I installed the new .dmg)

rbohan commented 5 years ago

(Rookie error - I confused the jdk and the jre versions of the java binary - all sorted now I think!)