failed to connect to server /xx.xx.xx.xx:20880 client-side timeout问题分析并解决

本文记录了一次解决Dubbo服务调用失败的过程,详细分析了客户端无法连接服务端的具体原因,包括服务启动状态、防火墙规则及端口映射等,并给出了最终解决方案。

一次离奇的排查dubbo服务问题之旅。

首先是开启服务提供者,正常启动,后来启动服务调用者,总是报错。错误如下:

2018-06-04 11:17:24,956(7063 ms)[WARN ][DubboClientReconnectTimer-thread-1]com.alibaba.dubbo.remoting.transport.
AbstractClient :  [DUBBO] client reconnect to 10.0.76.21:30000 find error . url: dubbo://10.0.76.21:30000/com.
lenovo.lps.push.common.rpc.MsgBroker?accepts=500&application=nginxKeepalivedService&check=false&codec=dubbo&dubbo
=2.5.3&heartbeat=60000&interface=com.lenovo.lps.push.common.rpc.MsgBroker&logger=log4j&methods=unsubscribe,
subscribe,publish,deleteMsg,publishJid,ack&pid=6048&retries=0&revision=2.6.6&side=consumer&timeout=10000×tamp=
1528082238672&version=1.0.0, dubbo version: 2.5.3, current host: 10.0.76.20com.alibaba.dubbo.remoting.Remoting
Exception: client(url: dubbo://10.0.76.21:30000/com.lenovo.lps.push.common.rpc.MsgBroker?accepts=500&application
=nginxKeepalivedService&check=false&codec=dubbo&dubbo=2.5.3&heartbeat=60000&interface=com.lenovo.lps.push.common.
rpc.MsgBroker&logger=log4j&methods=unsubscribe,subscribe,publish,deleteMsg,publishJid,ack&pid=6048&retries=0&
revision=2.6.6&side=consumer&timeout=10000×tamp=1528082238672&version=1.0.0) failed to connect to server /10.0.76
.21:30000 client-side timeout 3000ms (elapsed: 3000ms) from netty client 10.0.76.20 using dubbo version 2.5.3
        at com.alibaba.dubbo.remoting.transport.netty.NettyClient.doConnect(NettyClient.java:127)
        at com.alibaba.dubbo.remoting.transport.AbstractClient.connect(AbstractClient.java:280)
        at com.alibaba.dubbo.remoting.transport.AbstractClient$1.run(AbstractClient.java:145)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

整个过程非常的耗时,猜测几个可能的情况。

1、服务提供者启动失败。

经过检查,发现启动了,并且监听的是30000端口。排除这个错误。


2、服务提供者没有绑定主机ip。

经过检查,发现配置了主机ip。

3、超时

我有两个服务提供者,两个均设置的超时时间是3000ms,一个可以访问,就这个不能访问,超时应该不存在。

4、防火墙 + 端口占用

首先,单纯防火墙的问题,导致外部无法访问本机30000端口的问题是不存在的,因为本机还有其他服务也会有监听端口,而其他端口就可以正常访问,唯独30000端口只有监听,却无法接收请求。

就卡在这个端口问题上,从服务启动来看,端口绑定在30000上,不存在端口占用问题,但是通过telnet命令,返回No route to host。很奇怪。而我通过telnet 另一个服务提供者,能够成功。这说明这个服务器上肯定是有问题的。


通过telnet访问另一个服务提供者,正确得到应答。


后来发现这个服务器原来装过docker,而这个服务最初是放在docker里面的,后来部署不方便,将docker里面的服务单独拿到外面,但是端口配置没有在防火墙规则里面删除。故导致30000端口被监听,但是,最终30000端口被映射到了docker一个容器的30000端口上,因此访问本机自身的监听端口就会有问题。


最终解决办法就是在防火墙规则里面去掉docker30000端口映射的这些规则,然后service iptables reload 即可。

172.16.214.8 busilink-hz-ali-prod...ge-02 /opt/java-service/lo...e.log 1761832490 content: [middleplatform-cloudstorage] [] [] [] 2025-10-30 21:54:41,730 [dubbo-client-heartbeat-reconnect-thread-1] ERROR org.apache.dubbo.remoting.exchange.support.header.ReconnectTimerTask:101 - [DUBBO] Fail to connect toHeaderExchangeClient [channel=org.apache.dubbo.remoting.transport.netty4.NettyClient [/172.16.214.8:39726 -> /172.16.214.37:20880]], dubbo version: 3.2.10, current host: 172.16.214.8, 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://172.16.214.37:20880/com.cloud.middleplatform.device.api.result.provider.DeviceChannelApi?application=middleplatform-cloudstorage-dubbo&background=false&category=providers,configurators,routers&check=false&codec=dubbo&deprecated=false&dubbo=2.0.2&dynamic=true&executor-management-mode=isolation&file-cache=true&generic=false&heartbeat=60000&interface=com.cloud.middleplatform.device.api.result.provider.DeviceChannelApi&loadbalance=roundrobin&methods=batchUpdateAccessLimit,channelPage,getChannelByDevChannelId,getChannelByDevChannelIdUnitTypes,getChannelByDevChannelIds,getChannelByDeviceId,getChannelByDeviceIds,getChannelByDeviceIdsNoPrivilege,getChannelByParam,getChannelDeviceIdUnitTypeByDeviceIds,statisticsAccessLimit&path=com.cloud.middleplatform.device.api.result.provider.DeviceChannelApi&payload=2010241024&pid=22968&prefer.serialization=fastjson2,hessian2&protocol=dubbo&release=3.2.10&retries=0&revision=1.0-SNAPSHOT&serialize.check.status=WARN&service-name-mapping=true&service.filter=-exception&side=consumer&sticky=false&timeout=5000&timestamp=1760176331019&unloadClusterRelated=false) failed to connect to server /172.16.214.37:20880, error message is:Connection refused: /172.16.214.37:20880 at org.apache.dubbo.remoting.transport.netty4.NettyClient.doConnect(NettyClient.java:235) at org.apache.dubbo.remoting.transport.netty4.NettyClient.doConnect(NettyClient.java:179) at org.apache.dubbo.remoting.transport.AbstractClient.connect(AbstractClient.java:242) at org.apache.dubbo.remoting.transport.AbstractClient.reconnect(AbstractClient.java:304) at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeClient.reconnect(HeaderExchangeClient.java:189) at org.apache.dubbo.remoting.exchange.support.header.ReconnectTimerTask.doTask(ReconnectTimerTask.java:56) at org.apache.dubbo.remoting.exchange.support.header.AbstractTimerTask.run(AbstractTimerTask.java:93)
最新发布
11-01
2025-08-26 10:13:54.669 ERROR 18293 --- [dubbo-client-idleCheck-thread-1] o.a.d.r.e.s.header.ReconnectTimerTask : [DUBBO] Fail to connect toHeaderExchangeClient [channel=org.apache.dubbo.remoting.transport.netty4.NettyClient [0.0.0.0/0.0.0.0:11791 -> null]], dubbo version: 3.1.9, current host: 10.102.25.247, 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://10.102.25.247:20880/com.longshare.ta.batch.api.RealTaQueryShareService?anyhost=true&application=ta-batch-dubbo&background=false&check=false&codec=dubbo&deprecated=false&dubbo=2.0.2&dubbo.endpoints=[{"port":20880,"protocol":"dubbo"}]&dubbo.metadata-service.url-params={"connections":"1","timeout":"1000000","version":"1.0.0","dubbo":"2.0.2","release":"3.1.9","side":"provider","port":"20880","protocol":"dubbo"}&dubbo.metadata.revision=68c3675807e76bf83d8c056ffade297a&dubbo.metadata.storage-type=local&dynamic=true&generic=false&group=TA_REAL&heartbeat=60000&interface=com.longshare.ta.batch.api.RealTaQueryShareService&loadbalance=leastactive&methods=getRealTaCoiMsgLogDealCount,getRealTaCoiMsgLogDealList,getRealTaCustCount,getRealTaCustList,getRealTaFailTradeCount,getRealTaFailTradeList,getRealTaFrqConfirmCount,getRealTaFrqConfirmList,getRealTaFundShareCount,getRealTaFundShareFlowCount,getRealTaFundShareFlowList,getRealTaFundShareList,getRealTaOpenConfirmCount,getRealTaOpenConfirmList,getRealTaQuickTransferList,getRealTaTradeCount,getRealTaTradeList,getRealTaTransactionAccoCount,getRealTaTransactionAccoList,realTaCustExportAll,realTaFrqConfirmExportAll,realTaFundShareExportAll,realTaFundShareFlowExportAll,realTaOpenAccountExportAll,realTaTradeExportAll,realTaTransactionAccoExportAll,statisticsFrqConfirm,statisticsFundShare,statisticsFundShareFlow,statisticsTaTrade,statisticsTaTradeFail&pid=18293&qos.enable=false&reference.filter=takeUserIdConsumerFilter&register.ip=10.102.25.247&release=3.1.9&retries=-1&service-name-mapping=true&service.filter=exceptionFilter,-exception&side=consumer&sticky=false&timeout=1000000&timestamp=1756172296636&unloadClusterRelated=false) failed to connect to server /10.102.25.247:20880, error message is:Connection refused: /10.102.25.247:20880 什么原因
08-27
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

luffy5459

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值