【Azure Redis 缓存】Redisson 连接 Azure Redis出现间歇性 java.net.UnknownHostException 异常
原创
©著作权归作者所有:来自51CTO博客作者lulight的原创作品,请联系作者获取转载授权,否则将追究法律责任
问题描述
在Java项目中,使用Redisson作为连接Redis的客户端,间歇性的出现了DNS Monitor throwable 错误。
DNSMonitor throwable="java.net.UnknownHostException: failed to resolve 'xxxxxx.redis.cache.chinacloudapi.cn'
Redisson版本为:
org.redisson:redisson:3.12.0
全部的异常信息为:
level=ERROR logger=org.redisson.connection.DNSMonitor throwable="java.net.UnknownHostException: failed to resolve 'xxxxxx.redis.cache.chinacloudapi.cn' after 2 queries
at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:901)
at io.netty.resolver.dns.DnsResolveContext.tryToFinishResolve(DnsResolveContext.java:860)
at io.netty.resolver.dns.DnsResolveContext.query(DnsResolveContext.java:328)
at io.netty.resolver.dns.DnsResolveContext.access$600(DnsResolveContext.java:63)
at io.netty.resolver.dns.DnsResolveContext$2.operationComplete(DnsResolveContext.java:377)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:502)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:495)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:474)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:415)
at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:540)
at io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:533)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:114)
at io.netty.resolver.dns.DnsQueryContext.setFailure(DnsQueryContext.java:220)
at io.netty.resolver.dns.DnsQueryContext.access$300(DnsQueryContext.java:43)
at io.netty.resolver.dns.DnsQueryContext$4.run(DnsQueryContext.java:170)
at io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38)
at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:127)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:405)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Caused by: io.netty.resolver.dns.DnsNameResolverTimeoutException: [/8.8.4.4:53] query timed out after 5000 milliseconds (no stack trace available)
" thread=redisson-netty-4-21 message="Unable to resolve xxxxxx.redis.cache.chinacloudapi.cn" fluentd=517d053c90c2 tag=logback.aliClient.10.218.192.150
问题分析
根据错误提示,在Github上找到 Redisson 和 Netty 都存在相似的问题。最后都建议升级 Redisson 版本到最新,同时也把 Netty 的版本升级到最新。
Regression: DNS resolver failing to find valid DNS record :https://github.com/redisson/redisson/issues/1625
DNS resolver failing to find valid DNS record : https://github.com/netty/netty/issues/8261
如果升级比较复杂的话,也可以将redisson的dnsMonitoringInterval参数设置为-1。
参考资料
Regression: DNS resolver failing to find valid DNS record : https://github.com/redisson/redisson/issues/1625
DNS resolver failing to find valid DNS record : https://github.com/netty/netty/issues/8261
[END]
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!