在使用httpClient客戶端工具時,須要設置標紅顏色的屬性,不然就會出現Connection is not open 這個異常,以及這個異常會引起其餘的一些異常。併發
httpClient默認鏈接數爲2,致使併發用戶超過2個時,響應時間增長,後來將鏈接數改爲32,性能提高16倍。工具
HttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
HttpConnectionManagerParams params = httpConnectionManager.getParams();
params.setConnectionTimeout(5000);
params.setSoTimeout(20000);
params.setDefaultMaxConnectionsPerHost(32);//very important!!
params.setMaxTotalConnections(256);//very important!!
this.client = new HttpClient(httpConnectionManager);
// 設置編碼
this.client.getParams().setContentCharset(CharsetHelper.GBK);
this.client.getParams().setHttpElementCharset(CharsetHelper.GBK);性能