Netty DNS resolver ignores provided DNS server address
See original GitHub issueExpected behavior
In netty 4.1.8.Final, following code works fine. However, in 4.1.9 it does not send the request to provided address and sends it to default name server stream instead.
import java.net.{InetAddress, InetSocketAddress}
import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.nio.NioDatagramChannel
import io.netty.resolver.dns.{DnsNameResolverBuilder, DnsServerAddresses}
/** Simple dns resolver for testing stuff
*/
object Cli extends App {
private val bossGroup = new NioEventLoopGroup()
val res = new DnsNameResolverBuilder(bossGroup.next())
.channelType(classOf[NioDatagramChannel])
.nameServerAddresses(DnsServerAddresses.singleton(new InetSocketAddress("customdns.com", 33220)))
.build()
println(res.resolve("testaddress.com").await().get())
}
If you run this code with netty 4.1.9 in debug mode, you can see it’s sending requests to system resolvers.
I suspect the problem is the doResolveUncached
in DnsNameResolver
where you check whether the address stream is null. I think you should check whether the nameServerAddress is null and if it is, you should default to system resolvers. if it is defined however, you should make it into a stream and use it. But maybe im missing something.
Netty version
4.1.8.Final is fine, 4.1.9.Final is broken
JVM version (e.g. java -version
)
1.8
OS version (e.g. uname -a
)
mac os
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Netty is unable to resolve a DNS name - java - Stack Overflow
I was able to resolve this changing the default DNS resolver as per a Reactor Netty issue here ...
Read more >DnsNameResolver xref - Netty
90 */ 91 public class DnsNameResolver extends InetNameResolver { 92 93 ... 564 * @param nameservers The addresses of the DNS servers which...
Read more >NameResolverProvider.NameResolverSpec (reactor-netty 1.0 ...
Enables an AddressResolverGroup of DnsNameResolver s that supports random selection of destination addresses if multiple are provided by the nameserver.
Read more >io.netty.resolver.dns.DnsNameResolver - Netty 4.1.72.Final 源码
15 */ 16 package io.netty.resolver.dns; 17 18 import io.netty.bootstrap. ... 551 * @param nameservers The addresses of the DNS servers which are used...
Read more >Added netty based DNS resolver. This is VERY similar to the ...
this resolver will ignore the TTL from the DNS server and use the minimum TTL or the ... Sets the list of the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i think the #2 makes sense … i think having to configure two things in order to set dns server will be confusing
see https://github.com/netty/netty/pull/6588