org.apache.http.TruncatedChunkException: Truncated chunk ( expected size: 47956; actual size: 35656)
在使用httpcomponents-client-4.2.1时,任务运行一段时间就抛出以下一场
下面是异常的堆栈信息:
org.apache.http.TruncatedChunkException: Truncated chunk ( expected size: 47956; actual size: 35656)
at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:186)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:138)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
at java.io.InputStreamReader.read(InputStreamReader.java:167)
at java.io.Reader.read(Reader.java:123)
at org.apache.http.util.EntityUtils.toString(EntityUtils.java:224)
at org.apache.http.util.EntityUtils.toString(EntityUtils.java:248)
at com.bw30.bjappmanage.common.service.impl.HttpClientServiceImpl$2.handleResponse(HttpClientServiceImpl.java:206)
at com.bw30.bjappmanage.common.service.impl.HttpClientServiceImpl$2.handleResponse(HttpClientServiceImpl.java:1)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1070)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1044)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:1035)
at com.bw30.bjappmanage.common.service.impl.HttpClientServiceImpl.getHttpEntityText(HttpClientServiceImpl.java:214)
at com.bw30.bjappmanage.task.data.crawl.LiquGetThread.run(LiquGetThread.java:73)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
1、如果是一直报这个错 说明是服务端问题(如服务器故意给你返回错误的数据);
2、如果偶尔报这个错 说明是客户端网络(如丢包)等问题造成的,可以考虑失败重试两次,如果还失败 可以考虑记下日志,定期重试。
这个也是属于很正常的行为,就如网络问题,只要考虑好如失败重试 等策略解决这种问题就行了。
可以看下httpclient源码
你盼望1000字节 但实际获取了100 (这个服务器可以直接给你返回少于指定的数据, 网络问题也可能会遭遇这个问题)
org.apache.http.TruncatedChunkException: Truncated chunk ( expected size: 47956; actual size: 35656)的更多相关文章
- nginx的坑-org.apache.http.TruncatedChunkException: Truncated chunk( expected size: 7752; actual size: 4077)
org.apache.http.TruncatedChunkException: Truncated chunk 项目中使用请求远程接口报错 ,项目是Spring-boot的,两个项目(A和B) , ...
- What does "size" in int(size) of MySQL mean?
What does "size" in int(size) of MySQL mean? https://alexander.kirk.at/2007/08/24/what-doe ...
- Java对象大小:size和retained size
最近看到网上很多文章讲如何计算java对象的大小(size),很多观点不敢苟同. 这是其中一篇比较靠前的文章,写的也比较全面: http://blog.csdn.net/iter_zc/article ...
- (python走过的坑)OpenCV中错误opencv-3.3.1\modules\highgui\src\window.cpp:339: error: (-215) size.width>0 && size.height>0 in function cv::imshow
第一次在python中使用OpenCV(cv2),运行时报错opencv-3.3.1\modules\highgui\src\window.cpp:339: error: (-215) size.wi ...
- param size: The requested size, in points.
param size: The requested size, in points. 字幕宽度的自适应 . fontScale c++ - OpenCV find the text Scale fro ...
- error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'
用Python打开图像始终提示错误 error: OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\highgui\src\window.c ...
- line 352 Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow
OpenCV 使用 createtrackerbar()报错问题 Error Error: Assertion failed (size.width>0 && size.heig ...
- Shallow Size 和 Retained Size
所有包含Heap Profling功能的工具(MAT, Yourkit, JProfiler, TPTP等)都会使用到两个名词,一个是Shallow Size,另一个是 Retained Size. ...
- 值得一提:关于 HDFS 的 file size 和 block size
转 http://blog.csdn.net/samhacker/article/details/23089157?utm_source=tuicool&utm_medium=referral ...
随机推荐
- loj#2129. 「NOI2015」程序自动分析
题目链接 loj#2129. 「NOI2015」程序自动分析 题解 额... 考你会不会离散化优化常数 代码 #include<queue> #include<cstdio> ...
- BZOJ 4552 [Tjoi2016&Heoi2016]排序 线段树的分裂和合并
https://www.lydsy.com/JudgeOnline/problem.php?id=4552 https://blog.csdn.net/zawedx/article/details/5 ...
- Codeforces.788C.The Great Mixing(bitset DP / BFS)
题目链接 \(Description\) 有k种饮料,浓度Ai给出,求用最少的体积配成n/1000浓度的饮料. \(Solution\) 根据题意有方程 (A1x1+A2x2+...+Anxn)/[( ...
- Putty的用法
大致内容罗列如下: · 最简单的使用,登录 SSH主机 · 中文乱码的处理 · PuTTY常用配置的说明 · 复制.粘贴 · 保存 ...
- putty失活不挂起运行
https://blog.csdn.net/c1481118216/article/details/53010963 以下方式是试过了https://www.cnblogs.com/mysqlplus ...
- centos 6 秘钥分发
http://www.cnblogs.com/chensiqiqi/p/6554055.html
- IIS远程发布(Web Deploy)
作为开发人员,我们之前发布应用很可能是拷贝开发环境上发布好的代码文件到应用服务器硬盘中,然后在IIS中部署网站. 但是今天我们讲的是如果直接在我们的开发环境通过VS远程发布网站到应用服务器上,这将极大 ...
- eclim CSearch macro 问题的解决过程备忘录
问题: CSearch 宏时. RuntimeException: Could not find file with URI because it is a relative path, and no ...
- nginx多站路由配置tomcat
server { listen 80; server_name 1.goal.cn; index index index.html index.htm index.jsp; root /www/ser ...
- C# Queue 和Stack的实现
Queue 和Stack的使用就不用多说吧,一个是先进先出,一个是后进先出. 这里我主要关注其实现原理. queue的实现如下: public class Queue<T> : IEnum ...