Unable to look up TXT record for host ****.****.mongodb.net from GCP ap

I have a single node GCP cluster with my spring-boot app running. I recently created a new DB [M10] cloud atlas and trying to connect it via my app. However, I keep getting the following error - screenshot attached

However, I am able to connect to my old DBs [M20 and M10] via the same GCP cluster and same spring-boot app.

I am unable to figure out what could be the reason? Any idea?

Thanks in advance
Pranav

Is there a final “Caused by” that’s cut off from that screen shot? That could help diagnose the issue. It’s possible that you’re running into https://jira.mongodb.org/browse/JAVA-4018, in which case updating the Java driver to 4.5.1 or later will fix it.

Is this a self-managed cluster, or are using Atlas, or some other service? I am pretty sure that Atlas always registers a TXT record in DNS, but other services may not.

final caused by :

I am using Atlas and spring-boot-starter-data-mongodb 4.6.0

the other 2 DBs are also from Atlas and I am able to connect to them

from the bug you referenced it looks like it may have re-appeared in 4.6.0.

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

You can see from the stack trace that it’s using mongodb-driver-core-4.4.0.jar.

Thanks for spotting that. But after upgrading I am still getting DNS issues

It is not the same address as before.

yeah… i deleted the previous DB and created new one

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?

looks like dig worked.

then maybe some issue with com.mongodb.internal.dns.DefaultDnsResolver ?

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]

Not necessarily, but I don’t have a hypothesis that explains what both of us are seeing. I think at this point you should open a support ticket (https://www.mongodb.com/docs/manual/support/) to try to get to the root cause.

Regards,
Jeff

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

Nevermind, just started happening in my local environment as well.