MongoDB Atlas Issue Connecting with Java

Hi All,

I have created an account on MongoDB Atlas and tried connecting to MongoDB Atlas Cluster using the Java code.

With the same java code I am able to connect to On-Premise MongoDB but not the Atlas Cluster.

INFO: Exception in monitor thread while connecting to server
com.mongodb.MongoSocketWriteException: Exception sending message
	at com.mongodb.internal.connection.InternalStreamConnection.translateWriteException(
	at com.mongodb.internal.connection.InternalStreamConnection.sendMessage(
	at com.mongodb.internal.connection.InternalStreamConnection.sendCommandMessage(
	at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(
	at com.mongodb.internal.connection.CommandHelper.sendAndReceive(
	at com.mongodb.internal.connection.CommandHelper.executeCommand(
	at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(
	at com.mongodb.internal.connection.InternalStreamConnectionInitializer.initialize(
	at com.mongodb.internal.connection.DefaultServerMonitor$
Caused by: No subject alternative names matching IP address 

Hi @Samir_Benjamin,

I think you are hitting a known issue where atlas CA certificate is not present in your jdk certificate trust store:

Please download the certificate from the link above and import it with keytool command to your trust store.


I think I had this issue when I was using the Oracle SDK but I solve this issue by using the OpenJDK instead.