使用Httpclient访问url,如何提高服务器响应速度?

时间:2016-10-31 07:51:17

标签: java web-crawler apache-httpclient-4.x

 HttpGet httpGet = new HttpGet(spliceurl);

 CloseableHttpClient httpClient = HttpClients.createDefault();

 RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout((int) (80000)).setConnectTimeout((int) (20000)).build();

 httpGet.setConfig(requestConfig);

 response = httpClient.execute(httpGet);


 content=EntityUtils.toString(response.getEntity(), "utf-8");

它总是告诉我:java.net.SocketTimeoutException:读取超时。 但是当我测试单个网址时,它的响应是及时的。那么,谁能说出问题是什么?

0 个答案:

没有答案