1
我使用ThreadSafeClientConnManager執行在Android後臺線程,建立與同時請求:Android ThreadSafeClientConnManager超時?
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
HttpProtocolParams.setUseExpectContinue(params, true);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
ClientConnectionManager connman = new ThreadSafeClientConnManager(params, registry);
client = new DefaultHttpClient(connman, params);
和執行與要求(請注意,我使用OUTH-路標):
HttpGet request = new HttpGet("https://" + API_HOST + "/" + API_VERSION + path);
OAuthConsumer consumer = new CommonsHttpOAuthConsumer(key, secret);
consumer.sign(request);
HttpResponse response = client.execute(request);
的問題是,一段時間後,我開始變得
java.net.SocketException: The operation timed out
我需要做一些事情來顯式釋放後的連接要求?
這幫了很多,謝謝! – 2010-08-10 18:09:15
鏈接404,找不到! – 2012-08-19 19:44:07