- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个问题,PoolingHttpClientConnectionManager 的 httpconnection 是什么?
我知道如果我们使用PoolingHttpClientConnectionManager
,它会减少建立连接的时间(例如ssl握手
,tcp Enter code herehandshake
等)因为它重用了连接。
但是,我对http连接重用的理解是保持 Activity 状态,当服务器支持它时我们可以使用它。如果主机不支持keep-alive连接,我们就无法与keep-alive的主机进行通信。
所以,这是我的问题,
如果我使用 PoolingHttpClientConnectionManager 来管理非保持 Activity 服务器环境上的连接,Connectionmanager 管理连接吗?或者它为每个请求创建连接?
如果ConnectionManager管理连接,那么ConnectionManager如何保持连接?管理器是否定期发送字节?
最佳答案
如果不定义 HttpClient 将充当连接可以无限期保持 Activity 状态,从 Apache http docs :
If the Keep-Alive header is not present in the response, HttpClient assumes the connection can be kept alive indefinitely.
如果您想定义保持 Activity 策略,请参阅 example :
ConnectionKeepAliveStrategy myStrategy = new ConnectionKeepAliveStrategy() {
@Override
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
HeaderElementIterator it = new BasicHeaderElementIterator
(response.headerIterator(HTTP.CONN_KEEP_ALIVE));
while (it.hasNext()) {
HeaderElement he = it.nextElement();
String param = he.getName();
String value = he.getValue();
if (value != null && param.equalsIgnoreCase
("timeout")) {
return Long.parseLong(value) * 1000;
}
}
return 5 * 1000;
}
};
关于java - PoolingHttpClientConnectionManager 如何管理连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46109431/
我正在使用 Apache PoolingHttpClientConnectionManager 创建连接池。但是我在日志中看到现有的空闲连接未使用,而是创建了一个新连接。下面是代码 PoolingHt
我正在使用 Apache PoolingHttpClientConnectionManager 创建连接池。但是我在日志中看到现有的空闲连接未使用,而是创建了一个新连接。下面是代码 PoolingHt
我有以下声明: PoolingHttpClientConnectionManager manager; Android Studio 返回错误: 错误:(113, 9) 错误:找不到符号类 Pooli
我有一个问题,PoolingHttpClientConnectionManager 的 httpconnection 是什么? 我知道如果我们使用PoolingHttpClientConnection
我的程序包含以下行,此时挂起,我不太清楚为什么。 PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClien
我正在使用 Spring 来实现以下目标: 在服务器上,我通过 REST 接口(interface)以 XML 格式接收数据。我想将数据转换为 JSON 并将其发布到另一个服务器。我的代码(我删除了一
所以我有一个 Spring 应用程序,我使用 PoolingHttpClientConnectionManager 为从此应用程序发出的所有 http 请求创建连接池。我只有一台主机可以调用,这意味着
org.apache.http.impl.conn.PoolingHttpClientConnectionManagerorg.apache.http.impl.nio.conn.PoolingNHt
我正在使用 httpClient 4.3.6,CloseableHttpClient 由 PoolingHttpClientConnectionManager 提供服务。 我当前的设置包括 200 个
这是我的使用方法- private static final PoolingHttpClientConnectionManager connPool; static { connPoo
我们想在 Glassfish 3.1 Open 的 EJB 容器中使用 HttpClient源版本。 在HttpClient documentation我们看到以下关于 BasicHttpClient
PoolingHttpClientConnectionManager 和 PoolingClientConnectionManager 之间有什么区别。为什么 PoolingClientConnect
我正在处理的 Web 服务需要将传入的 json 数据发送到另一个服务的 REST 接口(interface)。为此,我编写了一个依赖于 Apache 项目的 HttpClient-lib 的小转发器
我正在尝试使用我正在使用的客户端代码在服务器上使用连接池(已配置 Https SSL)PoolingHttpClientConnectionManager 和我有一个带连接池的工作代码,但我想知道我的
我正在编写一个需要运行许多并行 http 请求的服务。它也将部署在自动扩展环境中,但我希望从每个服务实例中获得尽可能多的性能。 我看到这篇文章How to determine the maximum
有人可以向我解释一下 setMaxPerRoute(max) 和 setMaxTotal(max) 在引用 HttpComponents PoolingHttpClientConnectionMana
所以我似乎在使用 PoolingHttpClientConnectionManager 时遇到与 DNS 主机名解析缓存相关的问题。我有一个可以调用外部服务的 api。此服务使用 Akamai 边缘缓
我们使用 Spring Boot 2 与 Actuator 和 Prometheus 来显示 Grafana 仪表板。我想添加 Apache Http Client PoolingHttpClient
我知道如何模拟 default HttpClient ,但是我如何模拟使用 PoolingHttpClientConnectionManager 创建的最新(v4.4)HttpClient与莫基托?
所以我最近在尝试使用 IDE 运行我们现有的测试套件时开始面临 TestNGException。最近我的意思是更新 intelliJ 和依赖项以尝试在最新版本上工作。失败的代码和堆栈跟踪如下 - 代码
我是一名优秀的程序员,十分优秀!