I can see why the CM pool is reporting different values. The object in the CM pool returned by CM.getRoutes() ends up with a different HttpRoute.hashCode() than the actual HttpRoute created just prior to invoking the service.
in method to execute service: public class HttpClientConnLimitTest { // keep reference to original object private static HttpRoute theRoute; public void run() { final URL url = new URL("https://HOSTNAME:PORTNO/GET/SERVICE/URI"); final String urlText = url.toString(); final String host = url.getHost(); final int portNo = url.getPort(); final String protocol = url.getProtocol(); final HttpHost httpHost = new HttpHost(host, portNo, protocol); final HttpRoute httpRoute = new HttpRoute(httpHost); theRoute = httpRoute; globalConnManagerPool.setMaxPerRoute(httpRoute, 200); ...rest of code the same... } in background thread monitoring pool: private void getPoolStats() { Set<HttpRoute> routes = cm.getRoutes(); for(final HttpRoute cmRoute : routes) { log("compare this cm-route with the-route:" + " cm-route-hash=" + cmRoute.hashCode() + "; the-route-hash=" + theRoute.hashCode() + "; cm-route-string=" + String.valueOf(cmRoute) + "; the-route-string=" + String.valueOf(theRoute) + "; equal=" + cmRoute.equals(theRoute) ); } ...rest of code the same... } output logged is: compare this cm-route with the-route: cm-route-hash =-365947017; the-route-hash =-365948386; cm-route-string ={s}->https://lx01796:2443; the-route-string={}->https://lx01796:2443; equal=false The HttpRoute objects are different: from cmRoute.hashCode() : -365947017 from theRoute.hashCode(): -365948386 The toString values show why they differ. The route stored by CM has been marked secure ({s}) while the actual HttpRoute object (theRoute) has not been marked secure ({}). from String.valueOf(cmRoute) : {s}->https://lx01796:2443 from String.valueOf(theRoute): {}->https://lx01796:2443 That is the reason for the issue. For some reason HttpRoute makes the decision to never check the HttpHost protocol to see if it is secure. Using new HttpRoute(HttpHost) will set “secure” to false every time. public HttpRoute(final HttpHost target) { this(target, null, Collections.<HttpHost>emptyList(), false, TunnelType.PLAIN, LayerType.PLAIN); } Yet, somewhere else down the line the CM correctly recognizes that this is an HTTP/s (secure) route and within the pool it has marked the route as such. By changing my code to use this other constructor and set “secure” based on the protocol we get correct per-route pool management. public HttpRoute(final HttpHost target, final InetAddress local, final boolean secure) { this(target, local, Collections.<HttpHost>emptyList(), secure, TunnelType.PLAIN, LayerType.PLAIN); } Output after changing the constructor in my example code: compare this cm-route with the-route: cm-route-hash =-1772283693; the-route-hash =-1772283693; cm-route-string ={s}->https://lx01796:2443; the-route-string={s}->https://lx01796:2443; equal=true Why the output from your test and mine differ - remains a mystery. But, thank god Oleg is very diligent in his toString() overrides. Without that I’d have never been able to discover any reason for this odd behavior. Hopefully this was helpful to someone other than just me. As always - thank you for this brilliant apache project Oleg. — Pete From: "ol...@apache.org<mailto:ol...@apache.org>" <ol...@apache.org<mailto:ol...@apache.org>> Reply-To: HttpClient Discussion <httpclient-users@hc.apache.org<mailto:httpclient-users@hc.apache.org>> Date: Thursday, February 25, 2016 at 8:26 AM To: HttpClient Discussion <httpclient-users@hc.apache.org<mailto:httpclient-users@hc.apache.org>> Subject: Re: pooling connection manager: changing max per route On Thu, 2016-02-25 at 16:15 +0000, Pete Keyes wrote: Thank you. Just to make sure . . . you used apache-hc version 4.4.1 for this test? I must confess I have used 4.5.2 but I do not recall any issues in the connection management code since 4.1. Oleg — Pete Keyes Starbucks Coffee Co. w: 206-318-5933 c: 206-914-4134 From: "ol...@apache.org<mailto:ol...@apache.org><mailto:ol...@apache.org>" <ol...@apache.org<mailto:ol...@apache.org><mailto:ol...@apache.org>> Reply-To: HttpClient Discussion <httpclient-users@hc.apache.org<mailto:httpclient-users@hc.apache.org><mailto:httpclient-users@hc.apache.org>> Date: Thursday, February 25, 2016 at 3:25 AM To: HttpClient Discussion <httpclient-users@hc.apache.org<mailto:httpclient-users@hc.apache.org><mailto:httpclient-users@hc.apache.org>> Subject: Re: pooling connection manager: changing max per route I ran your code and did not see a single log entry with 'max-allowed=50'. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org<mailto:httpclient-users-unsubscr...@hc.apache.org> For additional commands, e-mail: httpclient-users-h...@hc.apache.org<mailto:httpclient-users-h...@hc.apache.org>