Make sure to *always* call method.releaseConnection() e.g. a finally
block. Even if the request was unsuccessful.
Massimo Signori wrote:
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
_________________________________________________________________
NOSE applied intelligence ag
ortwin glück [www] http://www.nose.ch
software engineer
hardturmstrasse 171 [pgp id] 0x81CF3416
8005 zürich [office] +41-1-277 57 35
switzerland [fax] +41-1-277 57 12
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]