On Tue, 2010-05-18 at 08:13 -0400, Brooks, Kenneth S wrote: > Awhile ago I mentioned that we have an issue where the following will happen > to a single request out of millions and millions. > The message is sent by httpclient. > Server receives the message. > Server (claims to) send the response. > Httpclient never sees it again. > > Even with the socket timeout set to minutes the response never makes it to > the client. > Then we get a Socket timeout exception: read timed out. > > I asked if it was possible to keep track of open connections and if any > particular thread was still active after XXX amount of time then be able to > call some custom code. > That way we can possibly inspect the running VM and not just logs after it > has happened. > > Oleg, you said that it wasn't really possible with httpclient 3 but it is > with 4 and I've since been able to upgrade to 4.. What did you have in mind > that would allow me to do this? >
HttpClient 4.0 framework allows for a custom connection implementation to be used instead of the standard one, which is not possible with HttpClient 3.x. http://hc.apache.org/httpcomponents-client-4.0.1/tutorial/html/advanced.html#d4e1063 HttpClient 4.0 maintains some basic statistics about the usage of a connection out of the box such as the total number of requests executed, responses received and total bytes sent and received: http://hc.apache.org/httpcomponents-core/httpcore/apidocs/org/apache/http/HttpConnection.html#getMetrics%28%29 http://hc.apache.org/httpcomponents-core/httpcore/apidocs/org/apache/http/HttpConnectionMetrics.html One possibility may be to extend the standard connection class and provide additional connection data such as the time of creation, last time accessed and what not. These attributes can be used by the connection manager to decide whether or not the connection should be reused. You could also extend the standard connection manager and make it expose these details though a custom API of some sort. Hope this helps Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
