【问题标题】:Web service client close connectionWeb 服务客户端关闭连接
【发布时间】:2010-12-19 20:57:51
【问题描述】:

我有一个 Glassfish 应用服务器来托管我的 Web 服务(带有 apache cxf 的 jax-rs)。

我有一个使用代码使用此 Web 服务的 Java 客户端:

Service service = JAXRSClientFactory.create("http://localhost/service", Service.class);

服务在运行时被消耗x 次数。 x 可能会有所不同。

一切都很好 - 代码运行良好且符合预期。

问题是服务器在达到 glassfish 的最大连接数后返回 http 500(在 http 服务下 - 保持活动状态)。然后在继续之前等待指定的超时秒数。这会一直重复,直到应用完成。

关于如何强制关闭连接因此永远不会达到最大连接限制的任何想法?

非常感谢。

【问题讨论】:

    标签: java web-services glassfish cxf


    【解决方案1】:

    抱歉,这是我的误解 - 它不是在每个请求都创建一个新连接,而是最大化单个连接。我将在超时等待或将最大连接数增加到合适的高数时进行编码。以下帮助:

    HTTP/1.1 by default, uses persistent connections in which a single connection is used by the client to make multiple requests. The server maintains the connection in the keep-alive state enabling the user agent to make subsequent requests on the same connection rather than create a new connection for every request (HTTP/1.0). The server closes a connection if one of the the following conditions are met.
    * The time elapsed between now and the last request has exceeded the value specified for the timeout-in-seconds parameter.
    * The number of requests using a connection has exceeded the value specified by the max-connections parameter.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-25
      • 2012-06-10
      • 2019-09-11
      • 2015-01-15
      相关资源
      最近更新 更多