22 / 22
Jan 2024

sorry i am using spring-boot-starter-data-mongodb 4.7.0 which internally uses 4.6.0 mongo java driver

any idea what might be wrong? I am using the same old username/pass combination that I have for the other 2 DB [no special character] . didn’t find anything relevant online

There’s something wrong with the new Atlas DB instances. There seems to be an issue only while connecting with the new DB. The old DB connection are working perfectly fine

Notice that now the TXT record is no longer failing (that happens first) but SRV lookup is still failing. Using dig, I’m able to resolve both TXT and SRV records for this host:

~$ dig SRV _mongodb._tcp.hk-prod.h8dkbpg.mongodb.net ; <<>> DiG 9.10.6 <<>> SRV _mongodb._tcp.hk-prod.h8dkbpg.mongodb.net ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19870 ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;_mongodb._tcp.hk-prod.h8dkbpg.mongodb.net. IN SRV ;; ANSWER SECTION: _mongodb._tcp.hk-prod.h8dkbpg.mongodb.net. 60 IN SRV 0 0 27017 ac-gokumri-shard-00-00.h8dkbpg.mongodb.net. _mongodb._tcp.hk-prod.h8dkbpg.mongodb.net. 60 IN SRV 0 0 27017 ac-gokumri-shard-00-01.h8dkbpg.mongodb.net. _mongodb._tcp.hk-prod.h8dkbpg.mongodb.net. 60 IN SRV 0 0 27017 ac-gokumri-shard-00-02.h8dkbpg.mongodb.net. ;; Query time: 167 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Sun Jun 12 12:08:08 EDT 2022 ;; MSG SIZE rcvd: 256 ~$ dig TXT _mongodb._tcp.hk-prod.h8dkbpg.mongodb.net ; <<>> DiG 9.10.6 <<>> TXT _mongodb._tcp.hk-prod.h8dkbpg.mongodb.net ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7702 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;_mongodb._tcp.hk-prod.h8dkbpg.mongodb.net. IN TXT ;; ANSWER SECTION: _mongodb._tcp.hk-prod.h8dkbpg.mongodb.net. 60 IN TXT "authSource=admin&replicaSet=atlas-tbk5qg-shard-0" ;; Query time: 35 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Sun Jun 12 12:08:57 EDT 2022 ;; MSG SIZE rcvd: 131

Can you try the same from the same server on which you’re running the Java application?

I think it is something in your environment. I am able to connect successfully to your cluster from both the mongo shell and a Java application.

If the issue was with the environment wouldn’t there be an issue connecting to other Atlas DB? [as mentioned previously, I am able to connect to the other 2 DB via the same GCP server, same application]

1 month later

Having the same issue as Pranav. GCP is failing to connect, works on my local environment. GCP works when connecting to older instances of Atlas.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfig' defined in URL [jar:file:/opt/app/server/app.jar!/BOOT-INF/classes!/com/devnotes/server/app/AppConfig.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.devnotes.server.app.AppConfig]: Constructor threw exception; nested exception is com.mongodb.MongoConfigurationException: Unable to look up TXT record for host dev.7f***.mongodb.net at org.springframework.beans.factory.support.ConstructorResolver.instantiate
10 months later

I’m facing the same issue, but did not find any solution on the forum here which works.
I can connect to a DB on cluster0.dnqegeu.mongodb.net or cluster0.xfzokj5.mongodb.net with the MongoDB Compass application,
BUT my java spring application fails to connect to a URI with mongodb+srv://
While the mongodb driver should use the SRV entries of the DNS, it looks for a TXT entry.
The library in use is mongodb-driver-core-4.8.2.jar
Any suggestion please?

The scheme mongodb+srv involves 2 types of DNS records. A TXT record which supplied connection string parameter and SRV records which provides a list of hosts to connect to. Looking for a TXT is thus normal behaviour.

What is the error message?

As for the 2 clusters you share I get:

;QUESTION cluster0.dnqegeu.mongodb.net. IN ANY ;ANSWER cluster0.dnqegeu.mongodb.net. 60 IN TXT "authSource=admin&replicaSet=atlas-c64af7-shard-0" cluster0.dnqegeu.mongodb.net. 60 IN SRV 0 0 27017 ac-eheduyb-shard-00-00.dnqegeu.mongodb.net. cluster0.dnqegeu.mongodb.net. 60 IN SRV 0 0 27017 ac-eheduyb-shard-00-01.dnqegeu.mongodb.net. cluster0.dnqegeu.mongodb.net. 60 IN SRV 0 0 27017 ac-eheduyb-shard-00-02.dnqegeu.mongodb.net.

and

;QUESTION cluster0.xfzokj5.mongodb.net. IN ANY ;ANSWER cluster0.xfzokj5.mongodb.net. 60 IN TXT "authSource=admin&replicaSet=atlas-kymzsm-shard-0" cluster0.xfzokj5.mongodb.net. 60 IN SRV 0 0 27017 ac-1b0f5hn-shard-00-00.xfzokj5.mongodb.net. cluster0.xfzokj5.mongodb.net. 60 IN SRV 0 0 27017 ac-1b0f5hn-shard-00-01.xfzokj5.mongodb.net. cluster0.xfzokj5.mongodb.net. 60 IN SRV 0 0 27017 ac-1b0f5hn-shard-00-02.xfzokj5.mongodb.net.

So both looks correct.

6 months later

I get similar issue when connect atlas. Finally I got reason that mongodb.net has been banned in Mainland China. The GFW test and ping test at China can’t connect to host dns.

3 months later

Hi! Iget similar problem. Can you please add sources of that information? I haven’t find anything about that mongodb.net is banned in Mainland China