I am using Azure to deploy my service, which would talk to MongoDB.
Previously, I am using Azure Linux App Service, and everything could work well.
However, I am trying to deploy my service onto Azure Windows App Service, but it would have DNS issue. Error log is as following:
org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.client.MongoClient]: Factory method 'mongoClient' threw exception; nested exception is com.mongodb.MongoConfigurationException: Unable to look up TXT record for host cluster0.xe4in.mongodb.netat org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)... 218 moreCaused by: com.mongodb.MongoConfigurationException: Unable to look up TXT record for host cluster0.xe4in.mongodb.netat com.mongodb.internal.dns.DefaultDnsResolver.resolveAdditionalQueryParametersFromTxtRecords(DefaultDnsResolver.java:131)at com.mongodb.ConnectionString.<init>(ConnectionString.java:384)at com.leland.config.MongoConfig.buildMongoClientSettings(MongoConfig.java:49)at com.leland.config.MongoConfig.mongoClient(MongoConfig.java:45)at com.leland.config.MongoConfig$$EnhancerBySpringCGLIB$$df102bd2.CGLIB$mongoClient$14(<generated>)at com.leland.config.MongoConfig$$EnhancerBySpringCGLIB$$df102bd2$$FastClassBySpringCGLIB$$11b79bd1.invoke(<generated>)at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)at com.leland.config.MongoConfig$$EnhancerBySpringCGLIB$$df102bd2.mongoClient(<generated>)at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.base/java.lang.reflect.Method.invoke(Method.java:566)at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)... 219 moreCaused by: javax.naming.CommunicationException: DNS error [Root exception is java.net.SocketTimeoutException: Receive timed out]; remaining name 'cluster0.xe4in.mongodb.net'at jdk.naming.dns/com.sun.jndi.dns.DnsClient.query(DnsClient.java:313)at jdk.naming.dns/com.sun.jndi.dns.Resolver.query(Resolver.java:81)at jdk.naming.dns/com.sun.jndi.dns.DnsContext.c_getAttributes(DnsContext.java:434)at java.naming/com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:235)at java.naming/com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:141)at java.naming/com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:129)at java.naming/javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:142)at com.mongodb.internal.dns.DefaultDnsResolver.resolveAdditionalQueryParametersFromTxtRecords(DefaultDnsResolver.java:114)... 232 moreCaused by: java.net.SocketTimeoutException: Receive timed outat java.base/java.net.TwoStacksPlainDatagramSocketImpl.receive0(Native Method)at java.base/java.net.TwoStacksPlainDatagramSocketImpl.receive(TwoStacksPlainDatagramSocketImpl.java:123)at java.base/java.net.DatagramSocket.receive(DatagramSocket.java:814)at jdk.naming.dns/com.sun.jndi.dns.DnsClient.doUdpQuery(DnsClient.java:423)at jdk.naming.dns/com.sun.jndi.dns.DnsClient.query(DnsClient.java:212)... 239 more
When using SSH onto the host, I am also seeing it not able to resolve the dns record, not matter with 8.8.8.8 or 1.1.1.1:
My connection string is like: mongodb+srv://xxxx:xxxxxxxxxxx@cluster0.xe4in.mongodb.net/db?retryWrites=true&w=majority
Does anyone have any clues on this?
Thank you!