请求/响应对的持久 HTTPUrlConnections 数量

发布于 2024-12-18 17:30:06 字数 204 浏览 2 评论 0原文

我有一个应用程序,它使用 HTTPUrlConnection 将肥皂信封发布到服务器并读取响应。我们遇到了一些问题,最有可能与服务器端可能错误地处理连接并使连接保持更长时间有关,这在当请求到来时,反过来会创建额外的新持久连接,而不是重新使用缓存的连接。

我想对 HTTPUrlConnection 的本质进行一些调查,特别是是否有办法找出特定客户端/服务器对的缓存中有多少连接。

I have an application that is using the HTTPUrlConnection to POST soap envelopes to a server and read the response in. We are having some problems, mostly likely to do with the server side potentially handling the connection incorrectly and keeping connections alive for longer, which in turn creates additional new persistent connections as requests come in rather than re-using the cached one.

I want to do some investigation into the nitty gritty of the HTTPUrlConnection, specifically if there is a way to find out how many connections are in the cache for a particular client/server pair.

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

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

发布评论

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

评论(1

尬尬 2024-12-25 17:30:06

您是否需要能够在运行时通过 Java API 确定此信息?如果是这样,那么我可能会建议使用 Apache HTTPClient 库,它提供了围绕此类事物的更多功能 - 包括它的 HttpConnectionManager 类。

如果您只需要确定创建了多少连接以及正在使用多少连接,我建议您通过 Wireshark 等工具进行一些监控。 (netstat 甚至 Windows 上的 Process Explorer 都可以用来查看打开的连接数量和连接位置等基本信息。)

Do you need to be able to determine this information through the Java API at runtime? If so, then I'd probably recommend using the Apache HTTPClient library instead, which provides many more features around this type of thing - including it's HttpConnectionManager class.

If you're only needing to determine how many connections are created and how many are in use, I'd recommend doing some monitoring through a tool like Wireshark. (netstat and even Process Explorer on Windows can be used to see the basics of how many connections are open and to where, etc.)

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