javaweb-servicesapache-axiskeep-alive

Axis Web Service Keep Alive


I have an axis web service running in Tomcat. Clients are making connections without sending a Connection: close header in HTTP 1.1 which means that the default is Keep-Alive. Unfortunately the client seems to be having a problem and when it gets an exception the client is not closing the connection. Since these clients are sending lots of traffic in batch jobs this quickly eats up all my connections. I want to force my web service to close each connection as soon as a particular Handler (extends BasicHandler) completes.

How do I do this? I.e. how do I force the server to close a connection after calling BasicHandler#invoke()?


Solution

  • In your tomcat's server.xml file, find the HTTP Connector definition (it's the element with protocol="HTTP/1.1"), and add the keepAliveTimeout attribute, as detailed here:

    http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

    You'll have to experiment with different values to see which gives you the behaviour you want. Check out the other settings also, some might be useful to you.

    Note that that's the Tomcat 6 docs, so not all options might work on tomcat 5, so check the same part of the tomcat 5 docs.