Scala Driver 2.9.0 connection fails with LoadBalancerSupportMismatch

I am using:
“org.mongodb.scala” %% “mongo-scala-driver” % “2.9.0”,

Connecting to a local mongodb works just fine but fails when trying to access Atlas with the following error:

{“ok”: 0, “errmsg”: “The server is being accessed through a load balancer, but this driver does not have load balancing enabled”, “code”: 354, “codeName”: “LoadBalancerSupportMismatch”}

My connection code is simple:
val mongoUri = “mongodb+srv://USER:PASSWORD@jpgnftdb.ld9qh.mongodb.net/myFirstDatabase?retryWrites=true&w=majority”
val mongoClient: MongoClient = MongoClient(mongoUri)
val database: MongoDatabase = mongoClient.getDatabase(mongoDBName)

The same connection string works fine from Nodejs

Actually the above error comes from using the older connection string format. With the above format I get this error:

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

Hi @JPEGGERS_Admin,

The 2.9.0 Scala driver is pre loadbalancer support. Please upgrade to the latest Scala driver 4.3.2.

Ross

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.