详细报错信息
2024-08-24 16:51:15 [dubbo-client-idleCheck-thread-1] ERROR o.a.d.r.transport.netty4.NettyClient
- [DUBBO] Failed to connect to provider server by other reason., dubbo version: 3.1.11, current host: 192.168.10.103, error code: 6-1. This may be caused by network disconnected, go to https://dubbo.apache.org/faq/6/1 to find instructions.
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: /192.168.10.103:20880
Caused by: java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:716)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
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:750)
2024-08-24 16:51:15 [dubbo-client-idleCheck-thread-1] ERROR o.a.d.r.e.s.h.ReconnectTimerTask
- [DUBBO] Fail to connect toHeaderExchangeClient [channel=org.apache.dubbo.remoting.transport.netty4.NettyClient [0.0.0.0/0.0.0.0:62553 -> null]], dubbo version: 3.1.11, current host: 192.168.10.103, error code: 6-16. This may be caused by , go to https://dubbo.apache.org/faq/6/16 to find instructions.
org.apache.dubbo.remoting.RemotingException: client(url: dubbo://192.168.10.103:20880/com.ruoyi.resource.api.RemoteMailService?anyhost=true&application=ruoyi-job&background=false&cache=false&check=false&codec=dubbo&deprecated=false&dubbo=2.0.2&dubbo.endpoints=[{"port":20880,"protocol":"dubbo"}]&dubbo.metadata.revision=7a9ab53291305598b1d3471ff4c8167b&dubbo.metadata.storage-type=remote&dynamic=true&generic=false&heartbeat=60000&interface=com.ruoyi.resource.api.RemoteMailService&logger=slf4j&metadata-type=remote&methods=send,sendWithAttachment&pid=2424&qos.enable=false®ister-mode=instance®ister.ip=192.168.10.103&release=3.1.11&service-name-mapping=true&side=consumer&sticky=false&timeout=3000×tamp=1724489284977&unloadClusterRelated=false&validation=true) failed to connect to server /192.168.10.103:20880, error message is:Connection refused: no further information: /192.168.10.103:20880
at org.apache.dubbo.remoting.transport.netty4.NettyClient.doConnect(NettyClient.java:224)
at org.apache.dubbo.remoting.transport.netty4.NettyClient.doConnect(NettyClient.java:171)
at org.apache.dubbo.remoting.transport.AbstractClient.connect(AbstractClient.java:220)
at org.apache.dubbo.remoting.transport.AbstractClient.reconnect(AbstractClient.java:274)
at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeClient.reconnect(HeaderExchangeClient.java:171)
at org.apache.dubbo.remoting.exchange.support.header.ReconnectTimerTask.doTask(ReconnectTimerTask.java:52)
at org.apache.dubbo.remoting.exchange.support.header.AbstractTimerTask.run(AbstractTimerTask.java:87)
at org.apache.dubbo.common.timer.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:653)
at org.apache.dubbo.common.timer.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:732)
at org.apache.dubbo.common.timer.HashedWheelTimer$Worker.run(HashedWheelTimer.java:454)
at java.lang.Thread.run(Thread.java:750)
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: /192.168.10.103:20880
Caused by: java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:716)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
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:750)
由于服务提供者被Stop后,服务消费者连接不上出现的错误。
默认配置
dubbo:
protocol:
name: dubbo
# dubbo 协议端口(-1表示自增端口,从20880开始)
port: -1
#心跳间隔,对于长连接,当物理层断开时,比如拔网线,TCP的FIN消息来不及发送,对方收不到断开事件,此时需要心跳来帮助检查连接是否已断开
heartbeat: 60000
heartbeat: 60000
就是每隔60秒去检查服务提供者是否可以连接,无法连接就会报上面的错
解决方法1:启动服务提供者,也就是这个dubbo服务192.168.10.103:20880
对应的应用服务。(dubbo服务是自动生成注册到注册中心的,应用服务被Stop后dubbo服务也会被Stop)
解决方法2:重启报错的这个服务即可。
官方issues:https://github.com/alibaba/spring-cloud-alibaba/issues/1259
重要文本
nacos作为服务注册中心,当服务端掉线(服务实例改变事件),dubbo重连任务每隔1分钟不间断进行。原因可能是spring-cloud-alibaba没有把服务实例改变消息传递进dubbo,也有可能是dubbo没有处理这个消息
重现:
配置服务端和消费端的注册中心为nacos:
1.服务端参数:dubbo.protocol.name=dubbo,dubbo.protocol.port=28801,dubbo.scan.base-packages=xx.xx.xx,dubbo.registry.address=spring-cloud://localhost
2.消费端参数:dubbo.consumer.check=false,dubbo.registry.address=spring-cloud://localhost
3. 启动服务端和消费端
4.修改服务端dubbo监听端口为: dubbo.protocol.port=28802
5.重启服务端
6. 消费端服务端业务正常。但消费端持续不断每隔1分钟连接服务端旧的28801端口。
配置服务端和消费端的注册中心为zookeeper:
1.服务端参数:dubbo.protocol.name=dubbo,dubbo.protocol.port=28801,dubbo.scan.base-packages=xx.xx.xx,dubbo.registry.address=zookeeper://127.0.0.1:2181
2.消费端参数:dubbo.consumer.check=false,dubbo.registry.address=zookeeper://127.0.0.1:2181
3. 启动服务端和消费端
4.修改服务端dubbo监听端口为: dubbo.protocol.port=28802
5.重启服务端
6. 消费端不会连接服务端旧的28801端口。消费端服务端业务正常。
以上场景模拟在docker容器中的场景,在docker容器中,微服务经常重新启动,重启微服务以后,其ip地址会发生变化(此处用端口变化模拟地址变化,道理是一样的)。
结论:
1、zookeeper作为服务注册中心,没有问题,
2、nacos作为服务注册中心,当服务端掉线(服务实例改变事件)并未处理该通道,造成重连任务不断进行。原因可能是spring-cloud-alibaba没有把服务实例改变消息传递进dubbo,也有可能是dubbo没有处理这个消息