【springCloud】feign.RetryableException: Read timed out executing GET.。的有效解决办法

1.错误如下图

在这里插入图片描述

2.解决办法

错误提示是请求超时,那我们就把请求的时间改大不久行了,这也是网上的大多数朋友给的解决方案,在网关配置ribbon:

ribbon:
  ConnectTimeout: 60000 # 连接超时时间(ms)
  ReadTimeout: 60000 # 通信超时时间(ms)

hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMillisecond: 60000 # 熔断超时时长:60000ms

如下图:这样可以解决问题,但是我的依然不能解决问题,可是网上的答案给我的方向都是延长时间,于是这个bug调了整整一天,发现是我的请求返回类型出错了,之前报的错是:说的是json格式,如是我将两个错误结合来看,跳出了思维怪圈,如果我的请求类型不对应就会引起json转换错误,同时也会时间超时。

feign.codec.DecodeException: Error while extracting response for type [class com.leyou.item.pojo.SpuDetail] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `com.leyou.item.pojo.SpuDetail` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `com.leyou.item.pojo.SpuDetail` out of START_ARRAY token
 at [Source: (PushbackInputStream); line: 1, column: 1]

	at feign.SynchronousMethodHandler.decode(SynchronousMethodHandler.java:174)
	at feign.SynchronousMethodHandler.executeAndDecode(S

经过检查:我的一个服务的返回的类型,与我调用的不相互匹配,如下

调用服务:所需要得到结果类型为SpuDetail对象

  SpuDetail spuDetail = this.goodsClient.querySpuDetailBySpuId(spu.getId());

被调用的服务:返回的类型为List。

  public ResponseEntity<List<SpuDetail>> querySpuDetailBySpuId(@PathVariable("spuId") Long spuId){

最后类型都统一成spuDetail就好了。即

  public List<SpuDetail> querySpuDetailBySpuId(@PathVariable("spuId") Long spuId)
  • 5
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值