hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad <b...@javawork.co.uk>
Subject Too many open sockets
Date Fri, 16 Nov 2007 10:54:40 GMT

I'm using http-commons to make some calls to a http server. There are
situations where I may have to make a large volumen of calls in a
short period of time.

My problem is that http-commons seems to be eating connections,
resulting in eventually getting this error

          java.net.BindException: Address already in use: connect

A quick netstat from the command prompt shows thousands of sockets
with status TIME_WAIT.

Here's my simple test code:

        public void testHttpGet() {

                HttpClient client = new HttpClient();
                GetMethod get = new GetMethod();

                try {

                        for (int i = 0; i < 10000; i++) {

                                int code = client.executeMethod(get);
                                byte[] responseBody =  get.getResponseBody();
                                System.out.println(i + ", response: " + code);

                } catch (Exception e) {
                } finally {


I checked the tutorial and I've made sure to read the response body. I
call recycle() in the loop and yet it still uses a new connection
every time.

All help very much appreciated.


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

View raw message