1
這裏是我用來創建我的多線程httpclient對象的代碼。我試圖在整個板子上有4秒的超時時間,所以如果沒有任何事情發生4秒鐘來放棄請求。我看到300秒範圍內的一些請求的執行時間非常長。我似乎無法弄清楚爲什麼會發生這種情況。有任何想法嗎?httpclient超時?可以似乎讓他們堅持
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParams, 4000);
HttpConnectionParams.setSoTimeout(httpParams, 4000);
// set request params
httpParams.setParameter("http.protocol.cookie-policy", CookiePolicy.BROWSER_COMPATIBILITY);
httpParams.setParameter("http.useragent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
httpParams.setParameter("http.protocol.wait-for-continue", 4000);
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
ClientConnectionManager cm = new ThreadSafeClientConnManager(httpParams,schemeRegistry);
HttpClient httpClient = new DefaultHttpClient(cm, httpParams);