說來真巧,2018年下半年時使用Thrift作為局域網服務rpc通信框架,整理了一下Thrift常見問題,博客訪問量較高,也有同學私信討論Thrift遇到的問題,此后的作業中,用dubbo比較多,好腦袋不如爛筆頭,經常排查dubbo問題,還是整理一下分享出來,
■ com.alibaba.dubbo.rpc.RpcException: No provider available for service
例外描述1(dubbo2.5.3):
com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method *** in the service com..**Service. No provider available for the service test/com..***Service from registry 192.168.40.21:2181 on the consumer 192.168.40.51 using the dubbo version 2.5.3. Please check if the providers have been started and registered.
例外描述2(dubbo2.7.3):
org.apache.dubbo.rpc.RpcException: No provider available from registry 192.168.40.84:2181 for service dev/com..**Service on consumer 192.168.48.96 use dubbo version 2.7.3, please check status of providers(disabled, not registered or in blacklist).
例外堆疊:
com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method getAgent in the service com.emaxcard.agent.modules.agent.service.AgentService.
No provider available for the service test/com.emaxcard.agent.modules.agent.service.AgentService from registry 192.168.40.21:2181
on the consumer 192.168.40.51 using the dubbo version 2.5.3. Please check if the providers have been started and registered. at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.checkInvokers(AbstractClusterInvoker.java:246) at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:55) at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:227) at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72) at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52) at com.alibaba.dubbo.common.bytecode.proxy1.getAgent(proxy1.java) at com.yft.service.impl.TAgentServiceImpl.getAgentInfo(TAgentServiceImpl.java:86)
產生原因:
No provider available--很明顯,就是說指定的服務在注冊中心不存在,
Please check if the providers have been started and registered.-請確保服務提供者已經啟動,并且已經注冊到注冊中心,
1. dubbo服務沒有啟動
2. dubbo服務不可用 / 在dubboadmin上做了disable操作

3. 如果使用了dubbo分組(group),可能是指定為這個group的dubbo服務沒有啟動
■ com.alibaba.dubbo.remoting.RemotingException: message can not send, because channel is closed
例外描述:
com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method *** in the service com..***Service. Tried 1 times of the providers [192.168.40.83:20899] (1/1) from the registry 192.168.40.21:2181 on the consumer 192.168.40.51 using the dubbo version 2.5.3.----Caused by: com.alibaba.dubbo.remoting.RemotingException: message can not send, because channel is closed .
例外堆疊:
2021-11-04 13:55:36.596 [ERROR] [riskOder_synchronizePlatOrder_1636005060003S457] [com.yft.service.impl.TAgentServiceImpl:89] *****獲得渠道商資訊,dubbo呼叫例外: com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method getAgent in the service com.emaxcard.agent.modules.agent.service.AgentService.
Tried 1 times of the providers [192.168.40.83:20899] (1/1) from the registry 192.168.40.21:2181 on the consumer 192.168.40.51 using the dubbo version 2.5.3.
Last error is: Failed to invoke remote method: getAgent,
provider: dubbo://192.168.40.83:20899/com.emaxcard.agent.modules.agent.service.AgentService?anyhost=true&application=youfu-merchant-consumer&bean.name=ServiceBean:com.emaxcard.agent.modules.agent.service.AgentService&check=false&default.check=false&default.group=test&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=test&interface=com.emaxcard.agent.modules.agent.service.AgentService&methods=saveAgent,selectSecondAndThirdAgent,getAgentByAgentCode,changeLoginPass,selectFirstAgent,listAgentByAgentName,initPassword,updateAgent,page,agentList,getAgentByName&pid=17492®ister=true&release=2.7.3&retries=0&revision=1.0.1-SNAPSHOT&side=consumer&timeout=3000×tamp=1635997957739,
cause: message can not send, because channel is closed .
url:dubbo://192.168.40.83:20899/com.emaxcard.agent.modules.agent.service.AgentService?anyhost=true&application=youfu-merchant-consumer&bean.name=ServiceBean:com.emaxcard.agent.modules.agent.service.AgentService&check=false&codec=dubbo&default.check=false&default.group=test&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=test&heartbeat=60000&interface=com.emaxcard.agent.modules.agent.service.AgentService&methods=saveAgent,selectSecondAndThirdAgent,getAgentByAgentCode,changeLoginPass,selectFirstAgent,listAgentByAgentName,initPassword,updateAgent,page,agentList,getAgentByName&pid=17492®ister=true&release=2.7.3&retries=0&revision=1.0.1-SNAPSHOT&side=consumer&timeout=3000×tamp=1635997957739 at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:101) at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:227) at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72) at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52) at com.alibaba.dubbo.common.bytecode.proxy1.getAgent(proxy1.java) at com.yft.service.impl.TAgentServiceImpl.getAgentInfo(TAgentServiceImpl.java:86) at ... Caused by: com.alibaba.dubbo.remoting.RemotingException: message can not send, because channel is closed .
url:dubbo://192.168.40.83:20899/com.emaxcard.agent.modules.agent.service.AgentService?anyhost=true&application=youfu-merchant-consumer&bean.name=ServiceBean:com.emaxcard.agent.modules.agent.service.AgentService&check=false&codec=dubbo&default.check=false&default.group=test&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=test&heartbeat=60000&interface=com.emaxcard.agent.modules.agent.service.AgentService&methods=updateStateAgent,saveAgent,selectSecondAndThirdAgent,getAgentByAgentCode,changeLoginPass,listAgentByName,getAgent,selectFirstAgent,listAgentByAgentName,initPassword,belongingSubordinate,reset,updateAgent,getHomeInfo,page,agentList,getAgentByName&pid=17492®ister=true&release=2.7.3&retries=0&revision=1.0.1-SNAPSHOT&side=consumer&timeout=3000×tamp=1635997957739 at com.alibaba.dubbo.remoting.transport.AbstractClient.send(AbstractClient.java:268) at com.alibaba.dubbo.remoting.transport.AbstractPeer.send(AbstractPeer.java:51) at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeChannel.request(HeaderExchangeChannel.java:112) at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeClient.request(HeaderExchangeClient.java:91) at com.alibaba.dubbo.rpc.protocol.dubbo.ReferenceCountExchangeClient.request(ReferenceCountExchangeClient.java:81) at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:96) at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:144) at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke$original$YXlgcHUl(MonitorFilter.java:75) at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke$original$YXlgcHUl$accessor$WxlrIuUu(MonitorFilter.java) at com.alibaba.dubbo.monitor.support.MonitorFilter$auxiliary$LX9nuPMk.call(Unknown Source) at org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstMethodsInter.intercept(InstMethodsInter.java:86) at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:53) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:48) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91) at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:74) at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53) at com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:77) ... 69 more
產生原因:
dubbo服務沒有啟動/dubbo服務掛掉了,此時,consumer會嘗試重新建立連接重新呼叫,重試次數取決于為屬性dubbo.consumer.retries配置的值,retries的默認值為2,對于增刪改操作,服務端要注意做冪等控制,避免出現重復處理的情況,當然,為了避免重復呼叫,有時我們會設定dubbo.consumer.retries=0,上面例外里Tried 1 times就是未重試,
■ org.apache.dubbo.remoting.TimeoutException: Waiting server-side response timeout by scan timer
例外描述:
Failed to invoke the method *** in the service com..***Service. Tried 1 times of the providers [192.168.40.48:20881] (1/1) from the registry 192.168.40.20:2181 on the consumer 192.168.40.85 using the dubbo version 2.7.3. Last error is: Invoke remote method timeout. cause: org.apache.dubbo.remoting.TimeoutException: Waiting server-side response timeout. start time: 2021-09-26 10:09:04.842, end time: 2021-09-26 10:09:34.871, client elapsed: 1 ms, server elapsed: 30028 ms, timeout: 30000 ms.
例外堆疊:
2021-09-26 10:09:27.888 [][] [DubboServerHandler-192.168.40.85:20888-thread-199] INFO com.emax.zhenghe.common.tracking.DubboTraceFilter:62 - found slow method:com.emax.zhenghe.portalapi.modules.enterprise.service.EnterpriseInfoApi:onlineAuthEnterpriseStatus,exec time:30030 ms 2021-09-26 10:09:34.873 [][] [EnterpriseInfoApiImpl_onlineAuthEnterpriseStatus1632622144838] ERROR c.e.z.rpcapi.provider.portal.EnterpriseInfoApiImpl:95 - 在線企業認證狀態獲取失敗 org.apache.dubbo.rpc.RpcException: Failed to invoke the method queryOrganizationStatus in the service com.auth.api.service.ContractSignOrganizationService.
Tried 1 times of the providers [192.168.40.48:20881] (1/1) from the registry 192.168.40.20:2181 on the consumer 192.168.40.85 using the dubbo version 2.7.3.
Last error is: Invoke remote method timeout. method: queryOrganizationStatus,
provider: dubbo://192.168.40.48:20881/com.auth.api.service.ContractSignOrganizationService?anyhost=true&application=zhenghe-provider&bean.name=ServiceBean:com.auth.api.service.ContractSignOrganizationService&check=false&deprecated=false&dubbo=2.0.2&dynamic=true&generic=false&group=test&interface=com.auth.api.service.ContractSignOrganizationService&lazy=false&methods=organizationStatusUpdate,getListByParam,getContractSignInfo,queryOrganizationStatus,organizationCreate,update,insert,list,updateOrganizationCreateStatus&pid=29399&qos.enable=false®ister=true®ister.ip=192.168.40.85&release=2.7.3&remote.application=auth-service-channel&retries=0&side=consumer&sticky=false&timeout=30000×tamp=1632622128250,
cause: org.apache.dubbo.remoting.TimeoutException: Waiting server-side response timeout by scan timer. start time: 2021-09-26 10:09:04.842, end time: 2021-09-26 10:09:34.871, client elapsed: 0 ms, server elapsed: 30028 ms, timeout: 30000 ms, request: Request [id=71603, version=2.0.2, twoway=true, event=false, broken=false, data=https://www.cnblogs.com/buguge/p/RpcInvocation [methodName=queryOrganizationStatus, parameterTypes=[class java.lang.String], arguments=[1626769691952966], attachments={input=696, path=com.auth.api.service.ContractSignOrganizationService, sw8-x=0- , sw8=1-M2EyNWZlODhlZGUzNDAwNjlhYmFiMmYzZWJhZWMyYjkuNzkuMTYzMjYyMjE0NDgxNzAyMjc=-NTVmOTViYWI1M2UwNGI4ZWE1ZTMxZTA5NmY4ZDM1MDEuMzgwLjE2MzI2MjIxNDQ4Mzg1MDc4-6-emhlbmdoZS1ycGNhcGktcHJvdmlkZXI=-emhlbmdoZS1ycGNhcGktcHJvdmlkZXJAYm9nb24=-dGVzdC9jb20uZW1heC56aGVuZ2hlLnBvcnRhbGFwaS5tb2R1bGVzLmVudGVycHJpc2Uuc2VydmljZS5FbnRlcnByaXNlSW5mb0FwaS5vbmxpbmVBdXRoRW50ZXJwcmlzZVN0YXR1cyhMb25nKQ==-MTkyLjE2OC40MC40ODoyMDg4MQ==, sw8-correlation=, interface=com.auth.api.service.ContractSignOrganizationService, version=0.0.0, timeout=30000, group=test}]], channel: /192.168.40.85:55882 -> /192.168.40.48:20881 at org.apache.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:113) at org.apache.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:248) at org.apache.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:78) at org.apache.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:55) at org.apache.dubbo.common.bytecode.proxy10.queryOrganizationStatus(proxy10.java) at ... Caused by: java.util.concurrent.ExecutionException: org.apache.dubbo.remoting.TimeoutException:
Waiting server-side response timeout by scan timer. start time: 2021-09-26 10:09:04.842, end time: 2021-09-26 10:09:34.871, client elapsed: 0 ms, server elapsed: 30028 ms, timeout: 30000 ms,
request: Request [id=71603, version=2.0.2, twoway=true, event=false, broken=false, data=https://www.cnblogs.com/buguge/p/RpcInvocation [methodName=queryOrganizationStatus, parameterTypes=[class java.lang.String], arguments=[1626769691952966], attachments={input=696, path=com.auth.api.service.ContractSignOrganizationService, sw8-x=0- , sw8=1-M2EyNWZlODhlZGUzNDAwNjlhYmFiMmYzZWJhZWMyYjkuNzkuMTYzMjYyMjE0NDgxNzAyMjc=-NTVmOTViYWI1M2UwNGI4ZWE1ZTMxZTA5NmY4ZDM1MDEuMzgwLjE2MzI2MjIxNDQ4Mzg1MDc4-6-emhlbmdoZS1ycGNhcGktcHJvdmlkZXI=-emhlbmdoZS1ycGNhcGktcHJvdmlkZXJAYm9nb24=-dGVzdC9jb20uZW1heC56aGVuZ2hlLnBvcnRhbGFwaS5tb2R1bGVzLmVudGVycHJpc2Uuc2VydmljZS5FbnRlcnByaXNlSW5mb0FwaS5vbmxpbmVBdXRoRW50ZXJwcmlzZVN0YXR1cyhMb25nKQ==-MTkyLjE2OC40MC40ODoyMDg4MQ==, sw8-correlation=, interface=com.auth.api.service.ContractSignOrganizationService, version=0.0.0, timeout=30000, group=test}]],
channel: /192.168.40.85:55882 -> /192.168.40.48:20881 at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357) at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1915) at org.apache.dubbo.rpc.protocol.AsyncToSyncInvoker.invoke(AsyncToSyncInvoker.java:56) at com.emax.zhenghe.common.tracking.DubboTraceFilter.invoke(DubboTraceFilter.java:32) at ... 78 common frames omitted
產生原因:
dubbo呼叫超時,服務端處理超時,dubbo超時時間通過dubbo.provider.timeout或dubbo.consumer.timeout來設定,dubbo默認超時時間是1000ms=1秒,客戶端dubbo呼叫超時后會嘗試重試,重試次數取決于上文的retries屬性,see dubbo超時重試
在生產環境,要控制dubbo超時時間,尤其是consumer端,timeout過長容易引起雪崩,
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/348150.html
標籤:Java
下一篇:JVM-記憶體區域與OOM
