Connection Fail on Mongo Atlas Serverless

Hello,
I’m using spring boot but I’m connected with mongo driver.
I’m having the following error:
nested exception is com.mongodb.MongoConfigurationException: A TXT record is only permitted to contain the keys [authsource, replicaset], but the TXT record for ‘mongo-serverless-dev.wyw1i.mongodb.net’ contains the keys [loadbalanced, authsource ]

I’m using java 11.

String connection:
mongodb+srv://accurta-dev:@mongo-serverless-dev.wyw1i.mongodb.net/?retryWrites=true&w=majority

Dependency version:

org.mongodb
mongodb-driver-sync
4.7.1

Code:
String connectionString = “mongodb+srv://acerta-dev:@mongo-serverless-dev.wyw1i.mongodb.net/test?retryWrites=true&w=majority”;

I need urgent help, I don’t know what else to do!!!

I suspect the issue is that you’re using an older driver version than you think you are. The driver added support for loadbalanced in the TXT record back in the 4.3.0 release, as you can see from this commit.

Please double check your mongodb-driver-core version to make sure it’s actually >= 4.3.0.

Regards,
Jeff

1 Like

Captura de Tela 2022-08-19 às 17.09.14
@Jeffrey_Yemin what else do i need besides this dependency?? there is nothing in the documentation, only referring to it

Generally that’s enough but I suspect you have a conflict somewhere in your configuration. Can you run something like mvn dependency:tree to see what version of mongodb-driver-core is being pulled in? If you can’t figure it out, try taking an explicit dependency on both mongodb-driver-core and bson at version 4.7.1 (these are both transitive dependencies of mongodb-driver-sync, so ordinarily they are pulled in automatically at the same version).

1 Like

OK. I configured and connection is OK!!
Captura de Tela 2022-08-19 às 17.56.29

But, I’m getting this error when I send something to the cluster:
ConnectionString connectionString = new ConnectionString(“mongodb+srv://acerta-dev:@mongo-serverless-dev.wyw1i.mongodb.net/?retryWrites=true&w=majority”);
MongoClientSettings settings = MongoClientSettings.builder()
.applyConnectionString(connectionString)
.serverApi(ServerApi.builder()
.version(ServerApiVersion.V1)
.build())
.build();
MongoClient mongoClient = MongoClients.create(settings);
MongoDatabase database = mongoClient.getDatabase(“test”);
database.createCollection(“example”);

Error:
org.mongodb.driver.cluster | SRV resolution completed with hosts: [mongo-serverless-dev-lb.wyw1i.mongodb.net:27017]
com.mongodb.MongoSocketWriteException: Exception sending message
at com.mongodb.internal.connection.InternalStreamConnection.translateWriteException(InternalStreamConnection.java:684)

Caused by: javax.net.ssl.SSLHandshakeException: extension (5) should not be presented in certificate_request

I`m not work with certificated

Try googling that error. You probably need to update your JVM. See this SO post, for one explanation.

I`im using GCP App Engine, not existe update JVM!!
Why resolve this problem??

I’m not sure I understand. Are you saying that it’s not possible for you to update the JVM?

There are some other idea here.

Exactly. With Google App Engine, it is not possible to change the JVM.
already tried this, but it doesn’t work either:
mvn spring-boot:run -Dspring-boot.run.profiles=local -Djdk.tls.client.protocols=TLSv1.2

What does java -version print? I’m surprised that Google would not be keeping up with the latest JDK patches. The JDK bug report lists the back ports: [JDK-8236039] JSSE Client does not accept status_request extension in CertificateRequest messages for TLS 1.3 - Java Bug System

Java verion is:
openjdk version “11.0.2” 2019-01-15

OpenJDK Runtime Environment 18.9 (build 11.0.2+9)

OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)

Is there any alternative to solve this? I really need to connect to atlas and it is being very problematic for java

It’s very concerning in general if Google App Engine isn’t keeping applications up to date with JDK patch releases, as this presents large security risks. According to their docs, they should be. I suggest checking with Google App Engine support to see what’s going on. I will look for workarounds if you’re not able to get anywhere on that front.

Regards,
Jeff

What would be the JVM version to end this problem?

Please if you have any alternative for java 11 let me know, otherwise I will have to leave the atlas product

Please try Java 17. That’s also an LTS release and the JDK bug was fixed before it went GA, so you shouldn’t need the latest patch release (though it’s still recommended).