dubbo服务RpcException异常:Tried 3 times of the providers 或com.alibaba.dubbo.remoting.TimeoutException:

异常信息:

Could not complete request
com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method getUserByPrimaryKey in the service com.dubbo.common.service.UserService. Tried 3 times of the providers [192.168.4.118:20880] (1/1) from the registry 127.0.0.1:2181 on the consumer 192.168.4.118 using the dubbo version 2.5.3. Last error is: Invoke remote method timeout. method: getUserByPrimaryKey, provider: dubbo://192.168.4.118:20880/com.dubbo.common.service.UserService?anyhost=true&application=dubboWeb&check=false&dubbo=2.5.3&interface=com.dubbo.common.service.UserService&methods=update,getUserByPrimaryKey,getUser,delete,getById,findPage,add,getUsers&pid=1156&revision=0.0.1-SNAPSHOT&side=consumer&timestamp=1492760542657, cause: Waiting server-side response timeout. start time: 2017-04-21 15:48:37.322, end time: 2017-04-21 15:48:38.325, client elapsed: 1 ms, server elapsed: 1001 ms, timeout: 1000 ms, 

 

Caused by: com.alibaba.dubbo.remoting.TimeoutException: Waiting server-side response timeout by scan timer.

最近在做一个项目,为了方便系统分离合并,采用dubbo实现,在debug测试过程中每次调用dubbo服务时就会产生异常,调用后台执行了三次,也就是服务调了三次,看后台总是看到一个tried 3 times……这也正是产生三次的原因,后来仔细看了后台异常说的是……timeout……,那么自然想到是服务超时,个人觉得是在调用一次服务时,后台需要执行的时间太长,超出了服务的响应超时时间(response timeout),所以它会再次尝试调用服务,可能是dubbo服务的设置,最多尝试三次,所以就会产生调用三次服务,修改dubbo服务的超时时间timeout,网上找设置dubbo timeout的方法,http://wenku.baidu.com/view/5c6854287375a417866f8f61,这里边仔细介绍了设置超时时间的方法,还进行了详细分析,开始设置的timeout=10000,少量的可以正常完成,可是数大点就不行了,后来有同事说可以设置timeout=0就没有超时时间,但是测试过,不可以,因为默认的是500,你设置了0,就是不管怎样都是超时了,这个和其他框架的配置不太一样,后来在服务提供端设置timeout=1200000,ok!完胜!虽然有点大,但是也没影响。一般情况设置为3000毫秒。

 

 详细设置和说明可以查看百度文库的资料,dubbo官方配置指南.doc,

<dubbo:service interface="com.XXXX.XXXXX.CardService" ref="cardService" timeout="1200000"/>

 

如果报错信息中有Serializable关键字,有可能是实体类没有序列化,dubbo是远程调用实现,在传输对象过程中,被传输的对象必须实现序列化,即 public class User implements Serializable {}。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值