Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.mongodb.MongoConfigurationException: Failed looking up SRV record #32991

Closed
rameshvenk opened this issue Apr 28, 2023 · 2 comments
Closed
Labels
area/mongodb kind/bug Something isn't working

Comments

@rameshvenk
Copy link

rameshvenk commented Apr 28, 2023

Describe the bug

Error Details

When trying to connect to Mongo Atlas using Quarkus, this error is produced

2023-04-28 08:33:52,405 INFO  [org.mon.dri.cluster] (cluster-ClusterId{value='644bcb3b740a8601c425ed16', description='null'}-srv-cluster-1.dzkfd.mongodb.net) Exception while resolving SRV records: com.mongodb.MongoConfigurationException: Failed looking up SRV record for '_mongodb._tcp.cluster-1.dzkfd.mongodb.net'.
        at com.mongodb.internal.dns.DefaultDnsResolver.resolveHostFromSrvRecords(DefaultDnsResolver.java:92)
        at com.mongodb.internal.connection.DefaultDnsSrvRecordMonitor$DnsSrvRecordMonitorRunnable.run(DefaultDnsSrvRecordMonitor.java:80)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: com.mongodb.MongoConfigurationException: Unable to look up SRV record for host _mongodb._tcp.cluster-1.dzkfd.mongodb.net
        at io.quarkus.mongodb.runtime.dns.MongoDnsClient.resolveSrvRequest(MongoDnsClient.java:152)
        at io.quarkus.mongodb.runtime.dns.MongoDnsClient.getResourceRecordData(MongoDnsClient.java:104)
        at com.mongodb.internal.dns.DefaultDnsResolver.resolveHostFromSrvRecords(DefaultDnsResolver.java:74)
        ... 2 more
Caused by: io.smallrye.mutiny.TimeoutException
        at io.smallrye.mutiny.operators.uni.UniBlockingAwait.await(UniBlockingAwait.java:64)
        at io.smallrye.mutiny.groups.UniAwait.atMost(UniAwait.java:65)
        at io.quarkus.mongodb.runtime.dns.MongoDnsClient.resolveSrvRequest(MongoDnsClient.java:138)
        ... 4 more


2023-04-28 08:33:52,407 INFO  [org.mon.dri.cluster] (vert.x-eventloop-thread-2) No server chosen by com.mongodb.client.internal.MongoClientDelegate$1@5bfcac08 from cluster description ClusterDescription{type=REPLICA_SET, srvResolutionException=com.mongodb.MongoConfigurationException: Failed looking up SRV record for '_mongodb._tcp.cluster-1.dzkfd.mongodb.net'., connectionMode=MULTIPLE, serverDescriptions=[]}. Waiting for 30000 ms before timing out

This was working successfully on 2.11.3.Final but breaks on 2.12.3.Final and 3.0.1.Final - I have not tested other versions > 2.12.3.Final

Expected behavior

Quarkus should connect to Mongo Atlas without this SRV lookup error

Actual behavior

Quarkus is able to lookup the SRV record for the Mongodb cluster, and then connect to the appropriate nodes

How to Reproduce?

Reproduce:
Using the free tier mongo atlas account, use the above mentioned quarkus versions and specify the mongo atlas cluster url in application.properties. Then, write a simple rest service that when invoked connects to mongo to retrieve records.

Output of uname -a or ver

Darwin chester.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64

Output of java -version

Darwin chester.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.11.3.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)

Additional information

On the version that does not work

2023-04-28 08:41:58,801 WARN  [io.net.res.dns.DnsServerAddressStreamProviders] (build-54) Can not find io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider in the classpath, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS.

However on the versions that do work

2023-04-28 08:50:12,609 WARN  [io.net.res.dns.DnsServerAddressStreamProviders] (build-34) Can not find {} in the classpath, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS.
@rameshvenk rameshvenk added the kind/bug Something isn't working label Apr 28, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 28, 2023

/cc @evanchooly (mongodb), @loicmathieu (mongodb)

@rameshvenk
Copy link
Author

Tested with Quarkus 3.0.2.Final and this issue seems to be resolved. This bug can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mongodb kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant