Dubbo 直连 Invoke remote method timeout 问题!

在测试环境消费者直连服务端进行测试时, 其中一个RPC接口抛出一个错误, 如下: 

Caused by: com.alibaba.dubbo.rpc.RpcException: Invoke remote method timeout. method: findByUserCode, provider: dubbo://localhost:22300/com.tkt.common.service.api.dubbo.system.HMemberCardsMyService?application=camee-demo-consumer&default.check=false&default.cluster=custom&default.reference.filter=custom&dubbo=2.0.1&interface=com.tkt.common.service.api.dubbo.system.HMemberCardsMyService&logger=slf4j&methods=findCount,findAllWithSort,save,update,findFirst,delete,findAll,findBySId,findByOpenIdAndSId,findByUserCode,findById,findPageWithSort,findAllCount,changeBalance,findByMobileAndSId,findFirstWithSort,findPage,findLast,findListWithSort,findPageDesc,findList,batchImport,findUnique&organization=wangchong&owner=camee&pid=29120&register.ip=192.168.1.72&side=consumer&timestamp=1559181693281, cause: Waiting server-side response timeout. start time: 2019-05-30 10:01:33.952, end time: 2019-05-30 10:01:34.954, client elapsed: 0 ms, server elapsed: 1002 ms, timeout: 1000 ms, request: Request [id=5, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=findByUserCode, parameterTypes=[class java.lang.String, class java.lang.Integer, boolean], arguments=[185851, 2, false], attachments={path=com.tkt.common.service.api.dubbo.system.HMemberCardsMyService, interface=com.tkt.common.service.api.dubbo.system.HMemberCardsMyService, version=0.0.0}]], channel: /192.168.1.72:63094 -> /192.168.1.72:22300
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:98) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.rpc.protocol.AbstractInvoker.invoke(AbstractInvoker.java:142) ~[dubbo-2.5.10.jar:2.0.1]
    at com.zoi7.component.dubbo.filter.CustomFilter.invoke(CustomFilter.java:24) ~[component-dubbo-2.1.0.jar:na]
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:68) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:74) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:68) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.rpc.protocol.dubbo.filter.FutureFilter.invoke(FutureFilter.java:53) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:68) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.rpc.filter.ConsumerContextFilter.invoke(ConsumerContextFilter.java:47) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:68) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.rpc.listener.ListenerInvokerWrapper.invoke(ListenerInvokerWrapper.java:73) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:51) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.common.bytecode.proxy2.findByUserCode(proxy2.java) ~[dubbo-2.5.10.jar:2.0.1]
    at com.tkt.common.service.demo.consumer.Runner.run(Runner.java:75) ~[target/:na]
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) [spring-boot-2.1.3.RELEASE.jar:2.1.3.RELEASE]
    ... 5 common frames omitted
Caused by: com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout. start time: 2019-05-30 10:01:33.952, end time: 2019-05-30 10:01:34.954, client elapsed: 0 ms, server elapsed: 1002 ms, timeout: 1000 ms, request: Request [id=5, version=2.0.0, twoway=true, event=false, broken=false, data=RpcInvocation [methodName=findByUserCode, parameterTypes=[class java.lang.String, class java.lang.Integer, boolean], arguments=[185851, 2, false], attachments={path=com.tkt.common.service.api.dubbo.system.HMemberCardsMyService, interface=com.tkt.common.service.api.dubbo.system.HMemberCardsMyService, version=0.0.0}]], channel: /192.168.1.72:63094 -> /192.168.1.72:22300
    at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:134) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture.get(DefaultFuture.java:111) ~[dubbo-2.5.10.jar:2.0.1]
    at com.alibaba.dubbo.rpc.protocol.dubbo.DubboInvoker.doInvoke(DubboInvoker.java:95) ~[dubbo-2.5.10.jar:2.0.1]
    ... 19 common frames omitted

 

分析:

  从字面意思来看, 就是说 RPC 接口请求超时了, 设置的1000ms, 实际达到了1002ms+

  但是我的服务端提供者明明已经设置了默认超时时间, 如下

  

  并且正式环境, 通过 zookeeper 注册中心访问时, 这个配置时间是生效的, 没有超时问题

  这就见了鬼了

  最后在消费者端加上了一个配置 (就可以了!!!): 

  

  或者在 reference 上加上 timeout 配置 (也可以!!!):

  

  

总结:

  当 使用 dubbo 服务直连时, 服务端提供者 配置的 provider.timeout 与 consumer.timeout 将不起作用, 实际调用时, 还是会采用 消费者端的配置(如果消费者没有配置, 那么就使用缺省配置: 1000ms)

  当 使用 注册中心 进行调用时, 提供者端的配置是能够起到作用的

  不知道这个 bug 会在哪个版本修复!

 

我使用的dubbo版本: 2.5.10

  

 

posted @ 2019-05-30 10:36  EEEEET  阅读(15719)  评论(0编辑  收藏  举报