I think I found issue with my own code. At one place i was checking
HTTP status.if  It was 404 I was not closing stream.
Once I started to do
EntityUtils.consume(entity);
at that time

everything start to happen as claimed.
rn

On Mon, Oct 24, 2011 at 7:06 PM, rangeli nepal <[email protected]> wrote:
> I am currently using httpcomponents-client-4.1.2 to connect to tomcat
> server hosted on a linux machine.
>
> As suggested by user guide I am taking following steps. Let me know if
> I am missing something
> Thanks in advance.
> rn
>
> 1. I am using ThreadSafeClientConnManager.
>
>
> schemeRegistry = new SchemeRegistry();
>
>           schemeRegistry.register(new Scheme("http", httpurl.getPort(),
> PlainSocketFactory.getSocketFactory()));
>           threadSaftClientConnManager=  new
> ThreadSafeClientConnManager(schemeRegistry,0,  TimeUnit.DAYS);
>        // Increase max total connection to 200
>           threadSaftClientConnManager.setMaxTotal(200);
>           // Increase default max connection per route to 20
>           threadSaftClientConnManager.setDefaultMaxPerRoute(20);
>           // Increase max connections for localhost:80 to 50
>           HttpHost localhost = new
> HttpHost(this.httpurl.getHost(),this.httpurl.getPort());
>           threadSaftClientConnManager.setMaxForRoute(new 
> HttpRoute(localhost), 50);
>
> 2. I use a monitoring thread that does something like this:
>
>                             wait(30000);
>                            // Close expired connections
>                            connMgr.closeExpiredConnections();
>                            // Optionally, close connections
>                            // that have been idle longer than 30 sec
>                            connMgr.closeIdleConnections(9, TimeUnit.SECONDS);
>
> 3. I was using KeepAliveStrategy. But disabling it giving me better
> CLOSE_WAIT rate.
>
> 4. I set following parameters:
>
> HttpParams httpParams = new BasicHttpParams();
>                HttpConnectionParams.setConnectionTimeout(httpParams, 5000);
>
>                HttpConnectionParams.setSoTimeout(httpParams, 5000);
>
>                //ConnManagerParams.setMaxTotalConnections(httpParams, 5000);
>
>                HttpProtocolParams.setVersion(httpParams, 
> HttpVersion.HTTP_1_1);
>                
> httpClient.getParams().setParameter("http.conn-manager.timeout", 120000L);
>
>                
> //httpClient.getParams().setParameter("http.protocol.wait-for-continue",
> 10000L);
>
>            httpClient.getParams().setParameter("http.tcp.nodelay", true);
>
> 5. I constantly see logs like follwing:
>
> - -- --------2011-10-24 23:03:14,987 DEBUG [Thread-16]:
> [ThreadSafeClientConnManager] Closing expired connections
>  - -- --------2011-10-24 23:03:14,987 DEBUG [Thread-16]:
> [ConnPoolByRoute] Closing expired connections
>  - -- --------2011-10-24 23:03:14,987 DEBUG [Thread-16]:
> [ThreadSafeClientConnManager] Closing connections idle longer than 9
> SECONDS
>  - -- --------2011-10-24 23:03:14,987 DEBUG [Thread-16]:
> [ConnPoolByRoute] Closing connections idle longer than 9 SECONDS
>  - -- --------2011-10-24 23:03:14,987 INFO  [Thread-16]:
> [DeceCacheClient] Testing Http Threads of cache for expired or idle
> status
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to