Arronlong / httpclientutil

该项目基于HttpClient-4.4.1封装的一个工具类。提供了更为简单的GET、POST及上传下载等功能。同时支持插件式配置Http-Header(包含自定义header)、配置SSL和Proxy等。
https://blog.csdn.net/xiaoxian8023/category_9264781.html
Apache License 2.0
1.41k stars 719 forks source link

发送超大文本数据的时候报错 #2

Closed kleen closed 8 years ago

kleen commented 8 years ago

private static HttpClient client= HCB.custom().timeout(30000*10).build();

{"Code":"xxxxxxx","Date":1450423000000,"dname":"二手","qvpn":"685"} 25000 条。

return HttpClientUtil.send(client,SystemConfiguration.getString("upload.system.api"), paramMap, context, "utf-8");

com.tgb.ccl.http.exception.HttpProcessException: java.net.SocketException: Connection reset by peer: socket write error at com.tgb.ccl.http.httpclient.HttpClientUtil.execute(HttpClientUtil.java:1536) at com.tgb.ccl.http.httpclient.HttpClientUtil.send(HttpClientUtil.java:1266) at com.tgb.ccl.http.httpclient.HttpClientUtil.send(HttpClientUtil.java:999) at com.tgb.ccl.http.httpclient.HttpClientUtil.send(HttpClientUtil.java:969)

kleen commented 8 years ago

??? 作者请问怎么解决

Arronlong commented 8 years ago

你是在说map中有2.5w条数据要发送,然后报错了?

kleen commented 8 years ago

恩。

kleen commented 8 years ago

INFO - I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:8080: Connection reset by peer: socket write error INFO - Retrying request to {}->http://localhost:8080 [01-18 13:40:06] DEBUG run() -batch acquisition of 1 triggers [01-18 13:40:06] DEBUG run() -Calling execute on job DEFAULT.jobtask [01-18 13:40:06] INFO upload() -上次未处理完成,退出本次处理 INFO - I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:8080: Connection reset by peer: socket write error INFO - Retrying request to {}->http://localhost:8080 INFO - I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:8080: Connection reset by peer: socket write error INFO - Retrying request to {}->http://localhost:8080

// 后台并未出现异常

Arronlong commented 8 years ago

我不太清楚你是怎么处理的。不过报这个错误肯定是由其中一方关闭了链接了。所以可以尝试设置本次为长连接,即: Header[] headers = HttpHeader.custom().connection(HttpHeader.Headers.KEEP_ALIVE).keepAlive("30000*10").build(); 然后在send时,传入headers。可以先试试这个方式。

Arronlong commented 8 years ago

是否正常请求了?

kleen commented 8 years ago

一样的报错。

Arronlong commented 8 years ago

请看这篇文章:http://my.oschina.net/xionghui/blog/508758?fromerr=UIXPTs9L