Arronlong/httpclientutil

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

Closed this issue · 8 comments

kleen commented

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

??? 作者请问怎么解决

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

kleen commented

恩。

kleen commented

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

// 后台并未出现异常

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

是否正常请求了?

kleen commented

一样的报错。