首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

HttpClient I/O exception,该如何解决

2012-12-18 
HttpClient I/O exceptionJava codeHttpClient client new HttpClient()PostMethod postMethod new P

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

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

热点排行
Bad Request.