So I'm trying to use just a single HttpClient for my entire
application. When I had one HttpClient per request, I would set the
per-Method timeouts on the HttpClient itself, but now that I'm using
only a single HttpClient, I'm not sure how to go about setting the
timeouts. I'd like to set the connection timeout and the 'so' timeouts
for each HttpMethod that I execute. I can see how to set the 'so'
timeout by calling method.getParams().setSoTimeout(), but can I set
the connection timeout in a similar way?

Thanks
Lowell

On 2/15/07, Bindul Bhowmik <[EMAIL PROTECTED]> wrote:
Lowell,

On 2/15/07, Lowell Kirsh <[EMAIL PROTECTED]> wrote:
> Ok, I've read some of the archives and see that other people are
> having the same problem as I am, where they end up with a ton of
> sockets in the CLOSE_WAIT state. What I would like to learn is not how
> to solve that problem in general, but how to solve it in my specific
> case.
>
> What I'm trying to do is create a WebServiceCall class. The way I've
> done it so far, which is not working out, is for each instance to
> represent a single call to a web service, and not be reusable. Each
> instance has its own HttpClient instance, which I know is wasteful,
> but I am not concerned with being overly efficient in this case.
>
> So how it works is like this: create a WebServiceCall, which creates a
> new HttpClient object. Then call WebServiceCall.execute() which calls
> something like _httpClient.execute(new GetMethod(_url)) and then calls
> releaseConnection() on the GetMethod object. That's it. So how should
> I configure or use the HttpClient objects so that I won't run out of
> file handles?

Ideally speaking you could reuse the same HttpClient instance for all
your requests. If you decide to use multiple HttpClient instances, you
need to shutdown the connection manager before releasing the instance
[1]. Unless you specify a connection manager explicitly, HttpClient
would be using a SimpleHttpConnectionManager[2].

Since you are running out of handles, I am assuming you are having a
good number of calls to the server(s), and if your application is
multi-threaded, it might be worth looking at the
MultiThreadedHttpConnectionManager class [3].

>
> thanks
> Lowell
>

[1]: http://jakarta.apache.org/commons/httpclient/performance.html
[2]: 
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/SimpleHttpConnectionManager.html
[3]: http://jakarta.apache.org/commons/httpclient/threading.html


--
Bindul Bhowmik
MindTree Consulting Ltd.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to