Web service client close connection
I have a Glassfish app server hosting my web service (jax-rs with apache cxf).
I have a Java client consuming this web service using code:
Service service = JAXRSClientFactory.create("http://localhost/service", Service.class);
The service is consumed x
number of times at run time开发者_运维百科. x
can vary.
All is good - the code runs fine and as expected.
The problem is that the server returns a http 500 after glassfish's max connections number is reached (under http service - keep alive). It then waits for the number of time out seconds specified before continuing. This repeats until app finishes.
Any ideas on how I can force the connection to close therefore the max connections limit will never be reached?
Much appreciated.
Apologies it was a misunderstanding on my part - its not creating a new connection every request, but maxing out the single connection. I will code in a time-out wait or up the max connections to a suitable high number. Below helped:
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.
精彩评论