Search code examples
javanettyredisson

Why netty throws UnknownHostException even though it received responses from nameservers?


Netty received responses from name servers for a host. Even then netty threw exception java.net.UnknownHostException.

Netty requesting DNS:

2019-01-18 03:49:43,754-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-3] DEBUG - [id: 0xe17fa005] WRITE: [6617: /10.102.5.110:53], DefaultDnsQuestion(host.removed.by.me.com. IN A)
2019-01-18 03:49:43,754-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-3] DEBUG - [id: 0xe17fa005] WRITE: [7076: /10.102.5.110:53], DefaultDnsQuestion(host.removed.by.me.com. IN AAAA)
2019-01-18 03:49:43,754-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-3] DEBUG - [id: 0x60682291] WRITE: [21843: /10.102.5.109:53], DefaultDnsQuestion(host.removed.by.me.com. IN A)
2019-01-18 03:50:22,739-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-3] DEBUG - [id: 0x60682291] WRITE: [17567: /10.102.5.109:53], DefaultDnsQuestion(host.removed.by.me.com. IN AAAA)

Responses from name servers for the host:

2019-01-18 03:50:22,739-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-14] DEBUG - [id: 0xe17fa005] RECEIVED: [6617: /10.102.5.110:53], DatagramDnsResponse(from: /10.102.5.110:53, to: /0.0.0.0:58780, 6617, QUERY(0), NoError(0), RD AA RA)
    DefaultDnsQuestion(host.removed.by.me.com. IN A)
    DefaultDnsRawRecord(host.removed.by.me.com. 3600 IN A 4B)
    DefaultDnsRawRecord(OPT flags:0 udp:4000 0B)
2019-01-18 03:50:22,739-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-14] WARN  - [id: 0xe17fa005] Received a DNS response with an unknown ID: 6617
2019-01-18 03:50:59,618-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-14] DEBUG - [id: 0xe17fa005] RECEIVED: [7076: /10.102.5.110:53], DatagramDnsResponse(from: /10.102.5.110:53, to: /0.0.0.0:58780, 7076, QUERY(0), NoError(0), RD AA RA)
    DefaultDnsQuestion(host.removed.by.me.com. IN AAAA)
    DefaultDnsRawRecord(removed.by.me.com. 3600 IN SOA 50B)
    DefaultDnsRawRecord(OPT flags:0 udp:4000 0B)
2019-01-18 03:50:59,618-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-14] WARN  - [id: 0xe17fa005] Received a DNS response with an unknown ID: 7076
2019-01-18 03:50:59,618-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-14] DEBUG - [id: 0x60682291] RECEIVED: [21843: /10.102.5.109:53], DatagramDnsResponse(from: /10.102.5.109:53, to: /0.0.0.0:58781, 21843, QUERY(0), NoError(0), RD AA RA)
    DefaultDnsQuestion(host.removed.by.me.com. IN A)
    DefaultDnsRawRecord(host.removed.by.me.com. 3600 IN A 4B)
    DefaultDnsRawRecord(OPT flags:0 udp:4000 0B)
2019-01-18 03:50:59,618-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-14] WARN  - [id: 0x60682291] Received a DNS response with an unknown ID: 21843
2019-01-18 03:50:59,634-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-14] DEBUG - [id: 0x60682291] RECEIVED: [17567: /10.102.5.109:53], DatagramDnsResponse(from: /10.102.5.109:53, to: /0.0.0.0:58781, 17567, QUERY(0), NoError(0), RD AA RA)
    DefaultDnsQuestion(host.removed.by.me.com. IN AAAA)
    DefaultDnsRawRecord(removed.by.me.com. 3600 IN SOA 50B)
    DefaultDnsRawRecord(OPT flags:0 udp:4000 0B)
2019-01-18 03:50:59,634-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-14] DEBUG - [id: 0x60682291] WRITE: [18300: /10.102.5.109:53], DefaultDnsQuestion(host.removed.by.me.com. IN CNAME)
2019-01-18 03:51:27,730-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-14] DEBUG - [id: 0x60682291] RECEIVED: [18300: /10.102.5.109:53], DatagramDnsResponse(from: /10.102.5.109:53, to: /0.0.0.0:58781, 18300, QUERY(0), NoError(0), RD AA RA)
    DefaultDnsQuestion(host.removed.by.me.com. IN CNAME)
    DefaultDnsRawRecord(removed.by.me.com. 3600 IN SOA 50B)
    DefaultDnsRawRecord(OPT flags:0 udp:4000 0B)

Netty threw exception:

2019-01-18 03:51:27,730-0600 [toe=01fl3wysf7tfpl] [redisson-netty-1-14] ERROR - failed to resolve 'host.removed.by.me.com' after 3 queries java.net.UnknownHostException: failed to resolve 'host.removed.by.me.com' after 3 queries 
    at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:845) [netty-resolver-dns-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:806) [netty-resolver-dns-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:333) [netty-resolver-dns-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:322) [netty-resolver-dns-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:779) [netty-resolver-dns-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.resolver.dns.DnsResolveContext.access$600(DnsResolveContext.java:62) [netty-resolver-dns-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.resolver.dns.DnsResolveContext$3.operationComplete(DnsResolveContext.java:382) [netty-resolver-dns-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511) [netty-common-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504) [netty-common-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483) [netty-common-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424) [netty-common-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.util.concurrent.DefaultPromise.trySuccess(DefaultPromise.java:103) [netty-common-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.resolver.dns.DnsQueryContext.setSuccess(DnsQueryContext.java:192) [netty-resolver-dns-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.resolver.dns.DnsQueryContext.finish(DnsQueryContext.java:184) [netty-resolver-dns-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.resolver.dns.DnsNameResolver$DnsResponseHandler.channelRead(DnsNameResolver.java:1127) [netty-resolver-dns-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) [netty-codec-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.nio.AbstractNioMessageChannel$NioMessageUnsafe.read(AbstractNioMessageChannel.java:93) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458) [netty-transport-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) [netty-common-4.1.30.Final.jar:4.1.30.Final]
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.30.Final.jar:4.1.30.Final]
    at java.lang.Thread.run(Thread.java:745) [?:1.7.0_60]

Why netty logged the following warning message? :

Received a DNS response with an unknown ID

Any reason netty did NOT accept/read the responses from the name servers for the host? Any configuration to get netty read it?


Solution

  • This was a netty's issue - https://github.com/netty/netty/issues/8261

    Patch resolving this issue applied in Redisson 3.10.1