本文介绍了Android的DefaultHttpClient默认的超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是什么是用于制作DefaultHttpClient如果我不指定它的请求默认的超时时间。

My questions is what is default timeout for requests made with DefaultHttpClient if I didn't specify it.

所以,如果没有code这样的

So if don't have code like this

HttpParams my_httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(my_httpParams, 3000);
HttpConnectionParams.setSoTimeout(my_httpParams, 1);

只是

HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setContentCharset(params,
                HTTP.DEFAULT_CONTENT_CHARSET);
ClientConnectionManager cm = new ThreadSafeClientConnManager(params,
                schemeRegistry);
SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("http", PlainSocketFactory
                .getSocketFactory(), 80));
return new DefaultHttpClient(cm, params);

多长时间这个HttpClient的等待服务器的响应?

How long will this httpClient wait for response from server?

推荐答案

据我知道的DefaultHttpClient连接超时,插座超时都是空(或零)默认情况下,这意味着超时不使用, Android应用程序将等待永远在理论上为连接插座的反应来完成。因此,强烈建议使用DefaultHttpClient时提供新的连接插座超时。

As far as I know the connection timeout and socket timeout for the DefaultHttpClient are both null (or zero) by default, which means that the timeouts are not used and Android application will wait theoretically forever for both the connection and socket response to complete. Therefore, it is highly recommended that to provide new connection and socket timeouts when using the DefaultHttpClient.

这篇关于Android的DefaultHttpClient默认的超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 10:31