【发布时间】:2010-07-02 12:12:46
【问题描述】:
我有类似下面的代码:
try {
HttpPost post = new HttpPost(httpsUrl);
setHeaders(post);
HttpEntity entity = new StringEntity(request, "UTF-8");
post.setEntity(entity);
HttpResponse response = httpclient.execute(post);
String result = EntityReader.readContent(response.getEntity());
checkAnswer(result);
return result;
} catch (Exception e) {
throw new ZapException("Error executing the http post request: "+e.getMessage(), e);
}
它使用以前可能已经使用过的 httpclient 实例通过 POST 将request 的内容发送到服务器(它打开了持久连接,因为我们正在向同一服务器发送相当多的请求...... )。
此有时会失败,并显示 SocketTimeoutException 并显示“读取超时”作为消息。
我们不清楚,为什么它只在某些时候失败,而大多数时候却没有。什么给了?
【问题讨论】:
-
我在使用 tomcat 7 向 solr 发送多个请求时遇到了类似的问题。您将请求发送到什么地方?您的服务器的详细信息是什么,因为那是错误的来源
-
我认为是 Jetty 6。但那是很久以前的事了......
标签: java post httpclient