Springboot latest version unable to connect to the serverless mongodb instance

My spring-boot service, running behind the AWS load balancer, needs to connect to the Serverless MongoDB instance.

I am using the latest spring-boot version — 2.5.5

The spring-boot service fails to connect to the serverless MongoDB with the below error message:

Caused by: com.mongodb.MongoConfigurationException: A TXT record is only permitted to contain the keys [authsource, replicaset], but the TXT record for ‘eyeplayserverlessinstan.iwf5e.mongodb.net’ contains the keys [loadbalanced, authsource]

My question: Is the serverless MongoDB, being in its beta version, supported by the Spring framework? And if it is supported, why is it not able to connect? Thanks!

I am using the below URL in my application.properties:

spring.data.mongodb.uri=mongodb+srv://my-username:my-password@eyeplayserverlessinstan.iwf5e.mongodb.net/my_db_collection?retryWrites=true&w=majority

spring.data.mongodb.database=my_db_collection

Welcome to the MongoDB Community Forums @Puneet_Pandey !

Atlas Serverless requires a minimum Java driver version of 4.3.0 (see: Minimum Driver Versions for Serverless Instances).

Per Spring’s Dependency Versions, Spring Boot 2.5.5 depends on the MongoDB 4.2.3 Java driver which does not have support for Atlas Serverless.

It looks like you will need the upcoming Spring Boot 2.6.0 release, which depends on the 4.3.2 MongoDB Java driver as of 2.6.0-M3.

Regards,
Stennie

@Puneet,
I am facing the same issue while connecting with serverless from my spring boot 2.3.5.R.
Are you able to connect now?

Thanks,
Santosh

Welcome to the MongoDB Community Forums @Santosh_Kumar_Singh!

If you are trying to connect to Atlas Serverless you will need Spring Boot 2.6.0 or newer.

If you are having trouble connecting to a different type of deployment, please start a new discussion topic with more details including your MongoDB server version, deployment type, and the specific error message received.

Thanks,
Stennie