Hi, I am trying to explain myself how the "keep-alive", or TCP connection persistence, is supposed to work? I have read several resources about that, but I still have some questions ( http://java.sun.com/j2se/1.5.0/docs/guide/net/http-keepalive.html
http://hc.apache.org/httpclient-3.x/performance.html http://www.io.com/~maus/HttpKeepAlive.html<http://www.io.com/%7Emaus/HttpKeepAlive.html> ). How can I verify that "keep-alive" is really used? I know that for http 1.1 keep-alive is by default, but does it mean that the TCP socket is reused? I mean how can I debug and verify that a TCP connection is reused. Does it mean that a socket is reused? I have executed several debug sessions using as a sample an Axis2 1.4 client, that in turns uses commons-httpclient-3.1. When I set client option: options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, "true"); Having two web services invocations from my client I can see that the HttpClient is really reused when the prop is set. The http connection used is of type MultiThreadedHttpConnectionManager$HttpConnectionAdapter The problem is that here stale connection check is enabled, so when the check is done as a consequence the connection (and its corresponding socket) used is closed and a new one is opened. I can read from http://hc.apache.org/httpclient-3.x/preference-api.htmlthat: "Disabling stale connection check may result in *slight* *performance*improvement at the risk of getting an I/O error when executing a request over a connection that has been closed at the server side." My general understanding is that in order to have a better performance a connection should be reused and its socket,too? My question is if it is a bad practice to disable stale connection check in order to reuse the connection and its socket? Why in commons-httpclient it is preferred to close and open a new connection: org.apache.commons.httpclient HttpMethodDirector private void executeWithRetry(final HttpMethod method): …. if (this.conn.getParams().isStaleCheckingEnabled()) { this.conn.closeIfStale(); - this is executed } …. Where I can read more about the benefit/tradeoff of having stale conn check? I will appreciate any information on the topic, because I have no much knowledge into this field. Thank you in advance, Dobri