您现在的位置是:首页 >技术交流 >Redisson cannot use an unresolved DNS server address问题解决网站首页技术交流
Redisson cannot use an unresolved DNS server address问题解决
简介Redisson cannot use an unresolved DNS server address问题解决
概述
本文记录Mac + IDEA开发,公司 + 远程办公时遇到的两个问题,记录一下。
问题
cannot use an unresolved DNS server address: [fe80::1%en0]:53
在家里,连上公司的VPN后,即可打开公司内网,远程办公。一切正常。某次,本地启动某个应用时报错:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisson' defined in class path resource [org/redisson/spring/starter/RedissonAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'redisson' threw exception;
nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'redisson' threw exception; nested exception is java.lang.ExceptionInInitializerError
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
Caused by: java.lang.ExceptionInInitializerError: null
at io.netty.resolver.dns.UnixResolverDnsServerAddressStreamProvider.parseSilently(UnixResolverDnsServerAddressStreamProvider.java:76)
at io.netty.resolver.dns.DnsServerAddressStreamProviders$1.provider(DnsServerAddressStreamProviders.java:57)
at io.netty.resolver.dns.DnsServerAddressStreamProviders$1.<init>(DnsServerAddressStreamProviders.java:36)
at io.netty.resolver.dns.DnsServerAddressStreamProviders.<clinit>(DnsServerAddressStreamProviders.java:34)
at org.redisson.connection.MasterSlaveConnectionManager.<init>(MasterSlaveConnectionManager.java:193)
at org.redisson.connection.MasterSlaveConnectionManager.<init>(MasterSlaveConnectionManager.java:156)
at org.redisson.config.ConfigSupport.createConnectionManager(ConfigSupport.java:189)
at org.redisson.Redisson.<init>(Redisson.java:123)
at org.redisson.Redisson.create(Redisson.java:162)
at org.redisson.spring.starter.RedissonAutoConfiguration.redisson(RedissonAutoConfiguration.java:145)
at org.redisson.spring.starter.RedissonAutoConfiguration$$EnhancerBySpringCGLIB$$5645a6ee.CGLIB$redisson$0(<generated>)
at org.redisson.spring.starter.RedissonAutoConfiguration$$EnhancerBySpringCGLIB$$5645a6ee$$FastClassBySpringCGLIB$$d05cdc13.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
at org.redisson.spring.starter.RedissonAutoConfiguration$$EnhancerBySpringCGLIB$$5645a6ee.redisson(<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)
Caused by: java.lang.IllegalArgumentException: cannot use an unresolved DNS server address: [fe80::1%en0]:53
at io.netty.resolver.dns.DnsServerAddresses.sanitize(DnsServerAddresses.java:179)
at io.netty.resolver.dns.DnsServerAddresses.sequential(DnsServerAddresses.java:67)
at io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider.<clinit>(DefaultDnsServerAddressStreamProvider.java:107)
报错分析:应用启动时,依赖注入RedissonClient,注入失败。
检查Redis启动是否正常,借助于Another Redis Desktop Manager工具,得知Redis单节点是正常的。由于是本地开发,故使用笔记本安装的本地Redis。另外,把127.0.0.1
换成localhost
,还是一样的报错信息。
附redisson-dev.yml
配置文件:
masterSlaveServersConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
failedSlaveReconnectionInterval: 3000
failedSlaveCheckInterval: 60000
password: null
subscriptionsPerConnection: 5
clientName: null
loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> { }
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
slaveConnectionMinimumIdleSize: 32
slaveConnectionPoolSize: 64
masterConnectionMinimumIdleSize: 32
masterConnectionPoolSize: 64
readMode: "SLAVE"
subscriptionMode: "SLAVE"
slaveAddresses:
- "redis://127.0.0.1:6379"
masterAddress: "redis://127.0.0.1:6379"
database: 0
threads: 0
nettyThreads: 0
codec: !<org.redisson.codec.FstCodec> { }
transportMode: "NIO"
想到之前为了解决另外一个问题时,有设置过IDEA的启动参数:-Djava.net.preferIPv4Stack=true
去掉这个启动参数,应用启动正常。
java.net.SocketException: Invalid argument
上面提到的问题,详细的报错日志为:
ERROR | org.apache.tomcat.util.net.NioEndpoint | log | 175 | - Error setting socket options
java.net.SocketException: Invalid argument
参考java-net-socketexception-invalid-argument-connect
在IDEA debug模式启动参数里新增配置-Djava.net.preferIPv4Stack=true
,报错消失。
注:我的开发环境
Mac:
芯片 Apple M2
MacOS 13.0 (22A380)
JDK:
openJDK 11
总结
在公司办公时,启动应用后,postman调试接口时偶尔报错,报错日志如上述问题2。下班后在家里办公时,启动应用报错日志,见上述问题1。
反思
为啥啊???
参考
风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。