Question

HttpUrlConnection uses persistent connections by default (http://download.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html). Is there any way to inspect Java HTTP connection pool? Eg check how many open connections in the pool?

Was it helpful?

Solution

Unfortunately no. In Oracle's VM, you can in theory inspect the static cache in sun.net.www.http.HttpClient.kac using reflection. This is a Map, which values are Stacks of cached HttpClient instances. The cache however also contains already closed or timed out connections and it does not seem to be a reasonable easy way to filter these out, without actually performing a real HTTP request, in which case abandoned connections will automatically reconnect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top