Re: Default IOReactorConfig instance has no socket timeout

2018-05-17 Thread Oleg Kalnichevski
On Wed, 2018-05-16 at 22:40 +0300, Дмитрий Жихарев wrote:
> Oleg,
> 
> realistically I would expect the default timeout to be around 5
> seconds, as is the default value in the
> PoolingHttpClientConnectionManager ( https://github.com/apache/httpco
> mponents-
> client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/ht
> tp/impl/io/PoolingHttpClientConnectionManager.java). IIRC, it was 2
> seconds in the 4.4 release. To me, for an http call 3 minutes looks
> like an eternity. But that's just my opinion.
> 
> I've made a small example: https://github.com/jihor/async-http-client
> -notimeout-demo
> 
> In the demo project, HttpAsyncClient 4.1.3 is used.
> 
> The example runs 2 http post's (one without timeout, the other with a
> timeout) on each of the following clients:
> 
>  
> 
> - (sync) client with default configuration
> (HttpClients.createDefault()). This client will wait endlessly if no
> timeout is defined in the request;
> 
> - (sync) client with custom RequestConfig. This client will always
> exit after its timeout expires even if the request has no timeout
> defined;
> 
> - asyncClient with default configuration
> (HttpAsyncClients.createDefault()). This client will wait endlessly
> if no timeout is defined in the request;
> 
> - asyncClient with custom connection manager and custom ioReactor.
> This client will always exit after its timeout expires even if the
> request has no timeout defined.
> 
>  
> 
> To me, it seems like a pitfall that default configurations offer
> unlimited timeouts for the requests which don't request specific
> timeouts using request configs. 
> 

Dmitry

There are plenty of web services (specially in the corporate world)
that take minutes to spit out some sort of a response back to the
client. 5 seconds as a default would be _way_ too aggressive in my
opinion. In fact, anything below a minute as a default could break a
lot of applications.

I am in favor of using a finite socket timeout by default in HC 5 but
it should be reasonably conservative.

Cheers

Oleg

-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org



Re: Default IOReactorConfig instance has no socket timeout

2018-05-16 Thread Дмитрий Жихарев
Oleg,

realistically I would expect the default timeout to be around 5 seconds, as is 
the default value in the PoolingHttpClientConnectionManager ( 
https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java).
 IIRC, it was 2 seconds in the 4.4 release. To me, for an http call 3 minutes 
looks like an eternity. But that's just my opinion.

I've made a small example: 
https://github.com/jihor/async-http-client-notimeout-demo

In the demo project, HttpAsyncClient 4.1.3 is used.

The example runs 2 http post's (one without timeout, the other with a timeout) 
on each of the following clients:

 

- (sync) client with default configuration (HttpClients.createDefault()). This 
client will wait endlessly if no timeout is defined in the request;

- (sync) client with custom RequestConfig. This client will always exit after 
its timeout expires even if the request has no timeout defined;

- asyncClient with default configuration (HttpAsyncClients.createDefault()). 
This client will wait endlessly if no timeout is defined in the request;

- asyncClient with custom connection manager and custom ioReactor. This client 
will always exit after its timeout expires even if the request has no timeout 
defined.

 

To me, it seems like a pitfall that default configurations offer unlimited 
timeouts for the requests which don't request specific timeouts using request 
configs. 


Regards, Dmitry Zhikharev


On May 16, 2018, 17:02, at 17:02, Oleg Kalnichevski  wrote:
>On Wed, 2018-05-16 at 15:16 +0300, Дмитрий Жихарев wrote:
>> Hi all!
>>
>> I was wondering if the IOReactorConfig.DEFAULT intentionally has
>> soTimeout set to ZERO_MILLESECONDS. Before version 5 there was also
>> connectTimeout, which also was 0 for the default builder. I
>> understand that the library can't make up its own mind on what
>> timeout the user requires, but isn't it a good practice for the
>> default config to have some sensible defaults so it doesn't hang
>> forever if something goes wrong?
>>
>> Regards, Dmitry Zhikharev
>>
>
>Hi Dmitry
>
>HttpClient 5.0 already uses finite (3 min) timeout values for connect
>and connection request operations.
>
>
>https://github.com/apache/httpcomponents-client/blob/master/httpclient5
>/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java#L44
>
>It is more difficult to say what the default value of socket timeout
>should be as different application might have different expectations
>and operational assumptions. 
>
>What kind of value would you propose?
>
>Oleg
>
>-
>To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
>For additional commands, e-mail: httpclient-users-h...@hc.apache.org


-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org



Re: Default IOReactorConfig instance has no socket timeout

2018-05-16 Thread Oleg Kalnichevski
On Wed, 2018-05-16 at 15:16 +0300, Дмитрий Жихарев wrote:
> Hi all!
> 
> I was wondering if the IOReactorConfig.DEFAULT intentionally has
> soTimeout set to ZERO_MILLESECONDS. Before version 5 there was also
> connectTimeout, which also was 0 for the default builder. I
> understand that the library can't make up its own mind on what
> timeout the user requires, but isn't it a good practice for the
> default config to have some sensible defaults so it doesn't hang
> forever if something goes wrong?
> 
> Regards, Dmitry Zhikharev
> 

Hi Dmitry

HttpClient 5.0 already uses finite (3 min) timeout values for connect
and connection request operations.


https://github.com/apache/httpcomponents-client/blob/master/httpclient5
/src/main/java/org/apache/hc/client5/http/config/RequestConfig.java#L44

It is more difficult to say what the default value of socket timeout
should be as different application might have different expectations
and operational assumptions. 

What kind of value would you propose?

Oleg 

-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org