setConnectionTimeout() only sets a timeout on the initial TCP connection
request. And setSoTimeout() sets a timeout on the socket operations. But if
the server is responding to normal TCP packets (whether they have any
payload or not) then this timeout will never be reached.

If you want to set a timeout on an overall HTTP operation you should setup
your own thread and call .abort() on the request (this method is
thread-safe). For example, I use this class and create a new instance of it
for every request I want to timeout. When I get a response, I interrupt my
timeout thread.

http://pastebin.com/sRZdZuKx


On Sun, Dec 16, 2012 at 7:11 PM, Jean-Marc Spaggiari <
[email protected]> wrote:

> Hi,
>
> What's the "right" way to configure the timeout with HttpClient 4.2.1?
>
> Here is what I'm doing:
>
>                         HttpParams params = client.getParams();
>                         HttpConnectionParams.setConnectionTimeout(params,
> 30000);
>                         HttpConnectionParams.setSoTimeout(params, 30000);
>                         result.result = client.execute (method);
>
> But I don't think it's working. Sometime it's taking way more than 30
> seconds.
>
> How should I proceed?
>
> I have setup a thread to kill the calls when they are taking to much time
>
> Thanks,
>
> JM
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to