如何解决Android中的org.apache.http.conn.ConnectTimeoutException?

时间:2014-02-10 08:15:04

标签: java android web-services exception connection-timeout

我正在处理与服务相关的应用程序。

DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpParams params = httpClient.getParams();
            HttpConnectionParams.setConnectionTimeout(params, 10000000);
            HttpConnectionParams.setSoTimeout(params, 15000000);
            HttpProtocolParams.setUseExpectContinue(httpClient.getParams(),true);

            String str_Server_Host = Control_PWD_Server_Name();
            String requestEnvelope = String.format(envelope_oe);
            // HttpPost httpPost = new HttpPost(str_Server_Host);
            HttpPost httpPost = new HttpPost(str_Server_Host);
            httpPost.setHeader("SOAPAction",
                    "http://tempuri.org/updateTransportStatus");
            httpPost.setHeader("Content-Type", "text/xml;charset=utf-8");
            httpPost.setEntity(new StringEntity(requestEnvelope));
            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();

            line = EntityUtils.toString(httpEntity);
            String str = Html.fromHtml(line).toString();

这是我得到的例外:

org.apache.http.conn.ConnectTimeoutException: Connect to /10.64.0.184:9092 timed out

如何解决android中的上述异常?请提供任何建议或相关的senario。

0 个答案:

没有答案