org.apache.http.TruncatedChunkException: Truncated chunk
2021-04-26 20:29
阅读:554
项目中使用请求远程接口报错 ,项目是Spring-boot的,两个项目(A和B) , A调用B的rest接口,返回json数据,A系统报错如下异常,B系统没有报错。
记录一下处理方式,方便再次遇到这个问题的人
#项目异常信息
org.apache.http.TruncatedChunkException: Truncated chunk ( expected size: 7752; actual size: 4077)
at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:186)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:138)
at ..service(.java:XXX)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.resteasy.plugins.server.servlet.FilterDispatcher.doFilter(FilterDispatcher.java:63)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:724)
当系统报以上错误时,接口表现出来的是数据传输不完整, 比如说接口返回 json , 那么接收到的数据可能会少一截,json 数据说不定会少个 } ,此时json就无法反序列化了。说白了就是丢包了。
通过大半天的查找,终于定位到是nginx的问题,因为nginx处理chunked传输有问题。
所以最简单的处理方式是把nginx的缓存关闭。
proxy_buffering off;
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:org.apache.http.TruncatedChunkException: Truncated chunk
文章链接:http://soscw.com/index.php/essay/79901.html
文章标题:org.apache.http.TruncatedChunkException: Truncated chunk
文章链接:http://soscw.com/index.php/essay/79901.html
评论
亲,登录后才可以留言!