检查 Java HTTP 连接池

发布于 2024-10-04 09:31:00 字数 155 浏览 0 评论 0原文

HttpUrlConnection 默认使用持久连接 (http://download.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html)。 有没有办法检查Java HTTP连接池?例如检查池中有多少个打开的连接?

HttpUrlConnection uses persistent connections by default (http://download.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html).
Is there any way to inspect Java HTTP connection pool? Eg check how many open connections in the pool?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

無心 2024-10-11 09:31:00

不幸的是没有。在 Oracle 的 VM 中,理论上您可以使用反射检查 sun.net.www.http.HttpClient.kac 中的静态缓存。这是一个 Map,其值是缓存的 HttpClient 实例的 Stack。然而,缓存还包含已经关闭或超时的连接,并且在不实际执行真正的 HTTP 请求的情况下过滤掉这些连接似乎不是一个合理且简单的方法,在这种情况下,废弃的连接将自动重新连接。

Unfortunately no. In Oracle's VM, you can in theory inspect the static cache in sun.net.www.http.HttpClient.kac using reflection. This is a Map, which values are Stacks of cached HttpClient instances. The cache however also contains already closed or timed out connections and it does not seem to be a reasonable easy way to filter these out, without actually performing a real HTTP request, in which case abandoned connections will automatically reconnect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文