question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Netty DNS resolver ignores provided DNS server address

See original GitHub issue

Expected 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:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tomashermancommented, Mar 27, 2017

i think the #2 makes sense … i think having to configure two things in order to set dns server will be confusing

0reactions
Scottmitchcommented, Mar 31, 2017
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found