hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mohit Anchlia" <mohitanch...@gmail.com>
Subject Re: CLOSE_WAIT
Date Mon, 20 Oct 2008 18:20:18 GMT
So I did enable the logging and I get this, does it mean that the
connections are being re-used:

2008-10-20 11:13:50,715 DEBUG - Should NOT close connection, using HTTP/1.1
2008-10-20 11:13:50,715 DEBUG - Releasing connection back to connection manager.
2008-10-20 11:13:50,715 DEBUG - Should NOT close connection, using HTTP/1.1
2008-10-20 11:13:50,715 DEBUG - Releasing connection back to connection manager.
2008-10-20 11:13:50,716 DEBUG - Set parameter http.connection.timeout = 121000
2008-10-20 11:13:50,716 DEBUG - Open connection to sim1.p.i.com:8080
2008-10-20 11:13:50,706 DEBUG - Should NOT close connection, using HTTP/1.1
2008-10-20 11:13:50,717 DEBUG - Adding Host request header
2008-10-20 11:13:50,718 DEBUG - Set parameter http.connection.timeout = 121000
2008-10-20 11:13:50,718 DEBUG - Open connection to localhost:80
2008-10-20 11:13:50,719 DEBUG - Adding Host request header
2008-10-20 11:13:50,716 DEBUG - Adding Host request header
2008-10-20 11:13:50,719 DEBUG - Open connection to sim1.p.i.com:8080
2008-10-20 11:13:50,719 DEBUG - Open connection to localhost:80
2008-10-20 11:13:50,719 DEBUG - Releasing connection back to connection manager.
2008-10-20 11:13:50,723 DEBUG - Open connection to localhost:80
2008-10-20 11:13:50,724 DEBUG - Adding Host request header
2008-10-20 11:13:50,718 DEBUG - Set parameter http.connection.timeout = 121000
2008-10-20 11:13:50,725 DEBUG - Open connection to sim1.p.i.com:8080
2008-10-20 11:13:50,726 DEBUG - Open connection to sim1.p.i.com:8080
2008-10-20 11:13:50,725 DEBUG - Open connection to sim1.p.i.com:8080
2008-10-20 11:13:50,725 DEBUG - Open connection to sim1.p.i.com:8080
2008-10-20 11:13:50,726 DEBUG - Set parameter http.connection.timeout = 121000
2008-10-20 11:13:50,726 DEBUG - Open connection to sim1.p.i.com:8080
2008-10-20 11:13:50,725 DEBUG - Open connection to sim1.p.i.com:8080
2008-10-20 11:13:50,728 DEBUG - Open connection to sim1.p.i.com:8080
2008-10-20 11:13:50,729 DEBUG - Set parameter http.connection.timeout = 121000
2008-10-20 11:13:50,730 DEBUG - Open connection to sim1.p.i.com:8080
2008-10-20 11:13:50,730 DEBUG - Resorting to protocol version default
close connection po

On Mon, Oct 20, 2008 at 10:05 AM, Oleg Kalnichevski <olegk@apache.org> wrote:
> On Sun, 2008-10-19 at 18:12 -0700, Mohit Anchlia wrote:
>> Thanks. Couple of questions. What do I expect to see when I turn on
>> the context logging?
>
> Debug logs
>
>> How do I determine if those connections are being
>> re-used?
>>
>
> You'll have analyze debug logs of the session.
>
>> Also, I am using log4j.xml and not log4j.properties, is there a place
>> that gives some example of configuring log4j.xml. If not then I'll
>> search log4j manuals.
>
> Actually reading the f manual sometimes truly helps
>
> Oleg
>
>>
>> Thanks again
>>
>> On Mon, Oct 13, 2008 at 2:40 PM, Oleg Kalnichevski <olegk@apache.org> wrote:
>> > On Mon, 2008-10-13 at 10:43 -0700, Mohit Anchlia wrote:
>> >> I saw quite a few posts on how to get rid of CLOSE_WAIT. And based on
>> >> those posts I changed my code but still I see CLOSE_WAITS. Below is my
>> >> test code:
>> >>
>> >>
>> >> public class Test {
>> >>     private static  MultiThreadedHttpConnectionManager con = new
>> >> MultiThreadedHttpConnectionManager();
>> >>     private static void doGet(HttpClient client) {
>> >>         System.out.println("CONN POOL " + con.getConnectionsInPool());
>> >>         //System.out.println("DEF CON "
>> >> +client.getHttpConnectionManager().getParams().getDefaultMaxConnectionsPerHost());
>> >>         //System.out.println("MAX CON " +
>> >> client.getHttpConnectionManager().getParams().getMaxTotalConnections()
>> >> );
>> >>
>> >>         GetMethod get = new GetMethod("http://localhost:8080/s/e");
>> >>                     get.setQueryString("version=V07.08&request_type=1");
>> >>              get.addRequestHeader( "Connection", "close");
>> >>         try {
>> >>             long statusCode = client.executeMethod(get);
>> >>             System.out.println(IOUtils.toString(get.getResponseBodyAsStream()));
>> >>             if (statusCode != HttpStatus.SC_OK) {
>> >>                            }
>> >>              Thread.sleep(1000);
>> >>         } catch(IOException ioe){
>> >>                 ioe.printStackTrace();
>> >>                     }catch (Exception e){} finally {
>> >>             if (get != null) get.releaseConnection();
>> >>         }
>> >>     }
>> >>     public static void main(String []a) throws Exception{
>> >>
>> >>         HttpConnectionManagerParams params = new HttpConnectionManagerParams();
>> >>         params.setDefaultMaxConnectionsPerHost(2);
>> >>         //params.setMaxConnectionsPerHost(2);
>> >>         params.setMaxTotalConnections(2);
>> >>         con.setParams(params);
>> >>
>> >>         HttpClient client = new HttpClient();
>> >>         client.getParams().setParameter("http.connection.timeout", new
>> >> Integer(1000));
>> >>        int i = 0;
>> >>        while ( i++ < 500){
>> >>         client = new HttpClient(con);
>> >>         doGet(client);
>> >>         client = null;
>> >>         con.closeIdleConnections(1000l);
>> >>         //con.deleteClosedConnections();
>> >>        }
>> >> /////////////
>> >>
>> >> so I am closing connection after each call, but still I see lot of
>> >> CLOSE_WAIT. Is there something that I am doing incorrectly? I was
>> >> expecting that above code will get rid of CLOSE_WAIT
>> >>
>> >
>> > Firstly, turn context logging on and see if HttpClient is reusing
>> > connections
>> >
>> > http://hc.apache.org/httpclient-3.x/logging.html
>> >
>> > Secondly, neither Thread#sleep() nor #closeIdleConnections() can
>> > guarantee exact timing. If you want all idle connections closed
>> > immediately you should pass 0 as a parameter to
>> > #closeIdleConnections();
>> >
>> > con.closeIdleConnections(0L);
>> >
>> > Hope this helps
>> >
>> > Oleg
>> >
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> >> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> >>
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message