On 12/09/2003 8:43 PM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have noticed that when a ConnectionTimeoutException is thrown,
> HttpConnection
> doesn't seem to release the connection. If a lot of timeouts are encountered,
> this eventually results in a hang when no more connections are available.
> Instead, the connection seems to be correctly released to the
> MultiThreadedHttpConnectionManager if a read timeout occurs,ie a
> java.net.SocketTimeoutException is thrown.
Hi,
It's generally considered a bad idea to depend on anyone but yourself to
release the connection. Essentially it follows the "you took it, you put it
back" method. So you should use a pattern like:
Try {
method.execute(...);
method.getResponseBodyAsString();
} catch (Exception e) {
...
} finally {
method.releaseConnection();
}
That will guarantee that the method is always released. A more detailed
example showing the best way to use HttpClient is in the tutorial
http://jakarta.apache.org/commons/httpclient/tutorial.html
Hope that helps,
Adrian Sutton.
----------------------------------------------
Intencha "tomorrow's technology today"
Ph: 38478913 0422236329
Suite 8/29 Oatland Crescent
Holland Park West 4121
Australia QLD
www.intencha.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]