当前位置: 代码迷 >> J2EE >> HttpClient I/O exception,该如何解决
  详细解决方案

HttpClient I/O exception,该如何解决

热度:598   发布时间:2016-04-22 00:20:40.0
HttpClient I/O exception
Java code
HttpClient client = new HttpClient();        PostMethod postMethod = new PostMethod("http://122.22.22.2:2222/Object/HrTms.do");        postMethod.setRequestHeader("Content-type",                "application/x-www-form-urlencoded; charset=UTF-8");        // 泛型List -> Json        java.lang.reflect.Type type = new com.google.gson.reflect.TypeToken<List<Tab_User>>() {        }.getType();        String json = gson.toJson(pageList, type);        _log.debug(serviceUrl + "发送 Hr Json:" + json);        postMethod.setRequestBody(new NameValuePair[] {                new NameValuePair("Type", "Hr"),                new NameValuePair("data", json)                 });        int status = 0;



在发送JSON比较大时,经常会出现一下异常:
[INFO ] [15:52:01] org.apache.commons.httpclient.HttpMethodDirector - I/O exception (org.apache.commons.httpclient.NoHttpResponseException) caught when processing request: The server 122.22.22.2:2222 failed to respond
[INFO ] [15:52:01] org.apache.commons.httpclient.HttpMethodDirector - Retrying request
[INFO ] [15:52:10] org.apache.commons.httpclient.HttpMethodDirector - I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
[INFO ] [15:52:10] org.apache.commons.httpclient.HttpMethodDirector - Retrying request

这就是丢失包?有没有什么办法解决或者尽量减少这种问题?
  相关解决方案