我正在使用 Apache Http Fluent API 4.3.2 定期向不太可靠的 API 发出 HTTPS 请求。我的代码如下所示:
try {
Request get = Request.Get(url);
get.connectTimeout(10000);
get.socketTimeout(10000);
Executor executor = Executor
.newInstance(HttpClientBuilder.create().build());
String response = executor.execute(get).returnContent().asString();
} catch (Exception e) {
LOG.error("Http get threw an exception", e);
}
它可以工作几天然后扔掉
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
execute
方法数百次。
在一些异常方法 execute
之后永远阻塞。
我可以建议执行程序用尽连接,但不知道如何处理。
一个月没有回音?我准备好接受“没有解决方案”这样的答案。
最佳答案
我遇到了同样的问题,在出现一些 404 错误后 Fluent 挂起。
我通过中止请求修复了它。
req.abort();
关于java - Apache Httpcomponent Fluent API 在一些 IO 错误后挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31857343/