hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Massimo Signori" <sign...@webscience.it>
Subject too many TCP connections using httpClient?
Date Thu, 21 Oct 2004 13:34:49 GMT
Hi everybody, this is my code: 

private void notifyTimeServer() {
        //
        logger.debug("notifyTimeServer, " + timerURL);
        //
        HttpClient client = new HttpClient();
        HttpMethod method = new GetMethod(timerURL);
        int statusCode = -1;
        for (int attempt = 0; statusCode == -1 && attempt <
MAX_CALLING_ATTEMPTS; attempt++) {
            //
            logger.debug("Establishing connection");
            //
            try {
                statusCode = client.executeMethod(method);
            }
            catch (Exception e) {
                //
                logger.error("Error calling jsp");
                //
            }
        }
        if (statusCode != -1) {
            //
            logger.debug("Connection estabilished");
            //
            byte[] responseBody = method.getResponseBody();
            method.releaseConnection();
        }
    }	  

I was looking with TCPView the number of TCP connections that this piece of
code is opening when talking to the server and I saw that opens an
incredible number of connections. All TCP connections are in TIME_WAIT
state.
Is there something wrong in this code? Or I'm forgetting something?

Best regards,

Massimo


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


Mime
View raw message