Feign报错feign.RetryableException: too many bytes written executing

  • SpringCloud Feign调用报错feign.RetryableException: too many bytes written executing

SpringCloud Feign调用报错feign.RetryableException: too many bytes written executing

版本:

SpringCloud : Greenwich.SR5

SpringBoot : 2.1.9.RELEASE

SpringCloudAlibaba : 2.1.0.RELEASE

看到这个错误第一时间我也是打开百度/Goole 但是搜出来的,无一例外 基本都是添加feign增强包 feign-httpclient 或者feign-okhttp 包;

无奈之下只好一步步debug 发现是把request.body 写入到流时发生的错误.java.io.IOException: insufficient data written

后面搜到body是跟Content-Length 有关系的… 附上博主链接 https://my.oschina.net/u/4410077/blog/3323588 看了之后 原来发生这个问题的原因跟我一样,因为服务之间调用需要携带一些用户信息之类的 所以实现了Feign的RequestInterceptor拦截器复制请求头,复制的时候是所有头都复制的,可能导致Content-length长度跟body不一致. 所以只需要判断如果是Content-length就跳过

原配置 :

/*** @author Joe* createTime 2020/06/10 18:13*/
@Log4j2
@Configuration
public class FeignConfiguration implements RequestInterceptor {@Overridepublic void apply(RequestTemplate template) {ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();HttpServletRequest request = attributes.getRequest();Enumeration<String> headerNames = request.getHeaderNames();if (headerNames != null) {while (headerNames.hasMoreElements()) {String name = headerNames.nextElement();String values = request.getHeader(name);template.header(name, values);}} else {log.info("feign interceptor error header:{}", template);}}
}

修改之后:

/*** @author Joe* createTime 2020/06/10 18:13*/
@Log4j2
@Configuration
public class FeignConfiguration implements RequestInterceptor {@Overridepublic void apply(RequestTemplate template) {ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();HttpServletRequest request = attributes.getRequest();Enumeration<String> headerNames = request.getHeaderNames();if (headerNames != null) {while (headerNames.hasMoreElements()) {String name = headerNames.nextElement();String values = request.getHeader(name);// 跳过 content-lengthif (name.equals("content-length")){continue;}template.header(name, values);}} else {log.info("feign interceptor error header:{}", template);}}
}

content-length详解参考文章 :https://juejin.im/post/5d772cb4e51d453b5f1a0502

Feign报错feign.RetryableException: too many bytes written executing相关推荐

  1. 转发: Feign报错feign.RetryableException: too many bytes written executing

    Feign报错feign.RetryableException: too many bytes written executing SpringCloud Feign调用报错feign.Retryab ...

  2. feign.RetryableException: too many bytes written executing POST

    在使用feign的时候 出现这个错误 记录一下 原代码如下 import feign.RequestInterceptor; import feign.RequestTemplate; import ...

  3. feign.RetryableException: too many bytes written executing

    fegin 远程调用报错 feign.RetryableException: too many bytes written executing POST - 解决办法 pom中添加依赖 <dep ...

  4. SpringCloud Feign调用报错feign.RetryableException: too many bytes written executing

    因为服务之间调用需要携带一些用户信息之类的 所以实现了Feign的RequestInterceptor拦截器复制请求头,复制的时候是所有头都复制的,可能导致Content-length长度跟body不 ...

  5. Request processin g failed; nested exception is feign.RetryableException: too many bytes written

    错误信息: 2020-09-08 14:07:14.718 ERROR 16146 --- [io-12000-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet ...

  6. nacos的feign报错Error creating bean with name ‘configurationPropertiesBeans‘ defined in class path reso

    nacos的feign报错Error creating bean with name 'configurationPropertiesBeans' defined in class path reso ...

  7. springboot feign too many bytes written executing

    报错 springboot feign too many bytes written executing 解決办法 <dependency><groupId>io.github ...

  8. python3报错 TypeError: can’t concat bytes to str 原因与解决方法

    在做项目的时候,Python3会报错如下错误: TypeError: can't concat bytes to str 意思是: 类型错误:无法将字节连接到字符串 类似的错误有: TypeError ...

  9. [cx_oracle]报错:expecting string or bytes object

    目标:将dataframe直接批量插入Oracle数据库 语句: # coding=utf-8 #设置语言环境 import os os.environ['NLS_LANG'] = 'SIMPLIFI ...

最新文章

  1. 李开复「预见2021」:自动化成企业升级转型刚需 | AI日报
  2. almost late for work
  3. cvpr2019 目标检测算法_CVPR2019 | 0327日更新12篇论文及代码汇总(多目标跟踪、3D目标检测、分割等)...
  4. 教师节特辑丨网易云信:素质教育「名师」是如何炼成的?
  5. bind配置进阶,转发器的配置以及如何实现子域授权。
  6. 只需订阅“全部文章”专栏便可查看所有文章
  7. pta:6-1单链表逆转(20分)
  8. JavaScript 引擎 V8 新机制:JIT-less
  9. Android 换行符号(\n)放到Android当中的TextView显示双斜杠(\\n)
  10. Orchard是如何运行的
  11. SpringBoot集成Redis分布式锁以及Redis缓存
  12. 不用MindManager打开mmap文件
  13. matlab dbns实现,matlab实现贝叶斯网络
  14. pycharm汉化包下载是某度网盘再现江湖?!不存在的!!真相就是如此简单~
  15. python风控建模培训
  16. 学术会议 Rebuttal 模板
  17. html5虚拟试衣,Trylive Clothing虚拟试衣系统 打造属于你个人的魔法试衣间
  18. 《MLB美职棒大联盟》:世界大赛最有价值球员奖
  19. 山西工商学院计算机二级网址,2021年山西工商学院教务处登录入口
  20. Mybatis 实现Mysql批量插入数据,判断数据是否存在

热门文章

  1. 永磁同步电机控制系统——模型预测控制(MPC)
  2. ORBSLAM-Atlas
  3. python四级属于什么水平_大学英语四级成绩等级划分是什么样的呢?
  4. 配置mysql环境变量之后,在命令行输入mysql命令无效的解决方法
  5. 大学计算机基础教学网站
  6. CentOS的DNS服务器配置文件/etc/resolv.conf重置问题
  7. 树莓派pico mpu6050 一阶互补滤波四元数法 解算姿态角
  8. Idea汉化安装后Settings无响应
  9. 真正的GHOXPGHOST纯净版“觉山孤鹤GHOSTXP纯净版”五一奉献
  10. 电子词典(用map改写)