You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Joan Balagueró <jo...@grupoventus.com> on 2018/10/19 13:08:41 UTC

Migration from Async 4.1.3 to HttpClient 5

Hello,

 

We are in the process of migrating to HttpClient5 from AsyncClient4.1.3, and
we have some quiestions:

 

1.       this.rc = RequestConfig.custom().setAuthenticationEnabled(false).

 
setConnectionRequestTimeout(Timeout.ofMillis(this.poolTimeout)).

 
setConnectionRequestTimeout(this.poolTimeout, TimeUnit.MILLISECONDS).

 
setConnectionTimeout(Timeout.ofMillis(this.connectionTimeout)).

 
setConnectTimeout(this.connectionTimeout, TimeUnit.MILLISECONDS).

 

                I wrote here the 4 possible methods ‘setConnectionxxxxx’.
The two first have the same name and different parameters, two ways to do
the same.

But the next two methods seem to be the same, but the method names are
different. Shouldn’t the fourth method be ‘setConnectionTimeout’ as well?

                

 

2.       The
PoolingAsyncClientConnectionManagerBuilder.setConnectionTimeToLive() is the
keep alive to set to connections in this pool?

(similar to what we do in HttpAsyncClients.custom().setKeepAliveStrategy()?)

 

3.       In previous AsyncClient, we set the setSocketTimeout at
RequestConfig level, so on each request I could copy this base ‘rc’ and
modify the response timeout.

But this method does no longer exist in RequestConfig. Where can I set the
response timeout now for each request?

 

4.       I imagine the PoolConcurrencyPolicy cannot be modified after
creating the pool …

 

5.       Before I had this method to set buffer sizes (and modify them on
the fly), getting the ConnectionConfig from the pool:

 

public void setBufferInInterface(int bufferInInterface) { 

 
this.phccm.setDefaultConnectionConfig(ConnectionConfig.custom().setBufferSiz
e(bufferInInterface).setFragmentSizeHint(bufferInInterface).build()); 

}

 

How can I do this now?

 

 

Thanks,

 

Joan.


Re: RV: Migration from Async 4.1.3 to HttpClient 5

Posted by Gary Gregory <ga...@gmail.com>.
On Fri, Nov 9, 2018 at 7:01 AM Oleg Kalnichevski <ol...@apache.org> wrote:

> On Fri, 2018-11-09 at 13:39 +0100, Joan Balagueró wrote:
> > Thanks Oleg. One more thing about the max connections with lax/strict
> > pool. Our code to modify the number of max connections is:
> >
> > public void setMaxConnections(int maxConnections)
> >  {
> >   this.phccm.setMaxTotal(maxConnections);
> >   this.phccm.setDefaultMaxPerRoute(maxConnections);
> > }
> >
> > If I modify (on the fly) the max connections in a strict pool it
> > works. For example I set a very low value and I start to receive
> > DeadlineTimeoutException, when I set a higher value the error
> > disappears. If I print the pool.getMaxTotal() I get the right value.
> >
> > But this does not work with a lax pool. I set up a lax pool with max
> > connections = 1, and no DeadlineTimeoutException is thrown (with the
> > same load). When I print the maxTotal and defaultMaxPerRoute I get 0
> > and 1 (instead of 1 and 1).
> >
> > Is this a bug or am I missing something?
> >
>
> Max total is not enforced by the lax pool, only max per route.
>

Hi,

Can you make sure this is Javadoc'd in the right places if it is not
already?

Gary

>
> Oleg
>
>
> > Thanks,
> >
> > Joan.
> >
> >
> > -----Mensaje original-----
> > De: Oleg Kalnichevski [mailto:olegk@apache.org]
> > Enviado el: jueves, 8 de noviembre de 2018 11:04
> > Para: HttpClient User Discussion
> > Asunto: Re: RV: Migration from Async 4.1.3 to HttpClient 5
> >
> > On Wed, 2018-11-07 at 19:30 +0100, Joan Balagueró wrote:
> > > Hello Oleg,
> > >
> > > We are finishing the migration and have the last questions:
> > >
> > > 1. If a connection is kept-alive for 30s at second 0, and after 10s
> > > is
> > > reused, this connection will die at second 30 or will survive
> > > until
> > > second 40?
> >
> > Keep-alive value is always relative to the last connection release.
> > If you want to limit the absolute connection life time please use set
> > a finite TTL (total time to live) value.
> >
> > >
> > > 2. Regarding the RetryHandler, below the method inherited from http
> > > 4.5 and modified to work with http5:
> > >
> >
> > I would recommend using DefaultHttpRequestRetryHandler shipped with
> > the library unless you have some application specific requirements.
> >
> >
>
> https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160
> >
> > > public boolean retryRequest(HttpRequest request, IOException
> > > exception, int executionCount, HttpContext context) {
> > >   // Don't retry if max retries are reached.
> > >   if (executionCount > this.maxExecutionCount) return false;
> > >
> > >   // Don't retry if any of these exceptions occur.
> > >   if (exception instanceof InterruptedIOException || exception
> > > instanceof UnknownHostException || exception instanceof
> > > ConnectException || exception instanceof SSLException) return
> > > false;
> > >
> > >   // Retry of if this request is considered 'idempotent'.
> > >   return (!(request instanceof HttpEntityEnclosingRequest)); }
> > >
> > > I understand the first two conditions are still ok (not sure if we
> > > have to add new exceptions on that list) but regarding the last
> > > condition,what would the equivalent condition be in Http5?
> > >
> >
> > I would suggest the following:
> >
> >
>
> https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160
> >
> >
> > >
> > > 3. We have increased the response time of our backend (ip ended
> > > with
> > > '182') in order to exhaust the strict/lax pool. When this happens
> > > the
> > > pool starts to throw a DeadlineTimeoutException. At this moment
> > > the
> > > number of sockets in TIME_WAIT increases a lot until making the
> > > server
> > > unresponsive (probably exhausting the local ports):
> > >
> > >  [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > > |
> > > wc -l
> > > 99
> > > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > > |
> > > wc -l
> > > 101
> > > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > > |
> > > wc -l
> > > 98
> > > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > > |
> > > wc -l
> > > 25876
> > > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > > |
> > > wc -l
> > > 61507
> > > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > > |
> > > wc -l
> > > 97615
> > >
> > > Is this the right behaviour? If Http5 cannot create new
> > > connections,
> > > so no new sockets are opened, why does the number of sockets in
> > > TIME_WAIT raise at those values?
> > >
> >
> > I believe it is. There is pretty good explanation of what the
> > TIME_WAIT state represents in our old wiki:
> >
> >
>
> https://wiki.apache.org/HttpComponents/FrequentlyAskedConnectionManagementQuestions
> >
> > Oleg
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: RV: Migration from Async 4.1.3 to HttpClient 5

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2018-11-09 at 15:19 +0100, Joan Balagueró wrote:
> Ok, so if I have a defaultMaxPerRoute = 1, and all requests I'm
> sending are using plain http to the same ip (without proxy) and only
> using 4 different ports  (8080, 8081, 8082, 8083), than this means I
> have 1 max connection for ip:8080, 1 for ip:8081, 1 for ip:80802 and
> 1 for ip:80803?
> Joan.
> 

Correct.

Oleg

> -----Mensaje original-----
> De: Oleg Kalnichevski [mailto:olegk@apache.org] 
> Enviado el: viernes, 9 de noviembre de 2018 15:01
> Para: HttpClient User Discussion
> Asunto: Re: RV: Migration from Async 4.1.3 to HttpClient 5
> 
> On Fri, 2018-11-09 at 13:39 +0100, Joan Balagueró wrote:
> > Thanks Oleg. One more thing about the max connections with
> > lax/strict 
> > pool. Our code to modify the number of max connections is:
> > 
> > public void setMaxConnections(int maxConnections)  {
> >   this.phccm.setMaxTotal(maxConnections);
> >   this.phccm.setDefaultMaxPerRoute(maxConnections);
> > }
> > 
> > If I modify (on the fly) the max connections in a strict pool it 
> > works. For example I set a very low value and I start to receive 
> > DeadlineTimeoutException, when I set a higher value the error 
> > disappears. If I print the pool.getMaxTotal() I get the right
> > value.
> > 
> > But this does not work with a lax pool. I set up a lax pool with
> > max 
> > connections = 1, and no DeadlineTimeoutException is thrown (with
> > the 
> > same load). When I print the maxTotal and defaultMaxPerRoute I get
> > 0 
> > and 1 (instead of 1 and 1).
> > 
> > Is this a bug or am I missing something?
> > 
> 
> Max total is not enforced by the lax pool, only max per route.
> 
> Oleg
> 
> 
> > Thanks,
> > 
> > Joan.
> > 
> > 
> > -----Mensaje original-----
> > De: Oleg Kalnichevski [mailto:olegk@apache.org] Enviado el: jueves,
> > 8 
> > de noviembre de 2018 11:04
> > Para: HttpClient User Discussion
> > Asunto: Re: RV: Migration from Async 4.1.3 to HttpClient 5
> > 
> > On Wed, 2018-11-07 at 19:30 +0100, Joan Balagueró wrote:
> > > Hello Oleg,
> > > 
> > > We are finishing the migration and have the last questions:
> > > 
> > > 1. If a connection is kept-alive for 30s at second 0, and after
> > > 10s 
> > > is reused, this connection will die at second 30 or will survive 
> > > until second 40?
> > 
> > Keep-alive value is always relative to the last connection release.
> > If you want to limit the absolute connection life time please use
> > set 
> > a finite TTL (total time to live) value.
> > 
> > > 
> > > 2. Regarding the RetryHandler, below the method inherited from
> > > http
> > > 4.5 and modified to work with http5:
> > > 
> > 
> > I would recommend using DefaultHttpRequestRetryHandler shipped
> > with 
> > the library unless you have some application specific requirements.
> > 
> > 
> 
> 
https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160
> > 
> > > public boolean retryRequest(HttpRequest request, IOException 
> > > exception, int executionCount, HttpContext context) {
> > >   // Don't retry if max retries are reached.
> > >   if (executionCount > this.maxExecutionCount) return false;
> > > 
> > >   // Don't retry if any of these exceptions occur.
> > >   if (exception instanceof InterruptedIOException || exception 
> > > instanceof UnknownHostException || exception instanceof 
> > > ConnectException || exception instanceof SSLException) return
> > > false;
> > > 
> > >   // Retry of if this request is considered 'idempotent'.
> > >   return (!(request instanceof HttpEntityEnclosingRequest)); }
> > > 
> > > I understand the first two conditions are still ok (not sure if
> > > we 
> > > have to add new exceptions on that list) but regarding the last 
> > > condition,what would the equivalent condition be in Http5?
> > > 
> > 
> > I would suggest the following:
> > 
> > 
> 
> 
https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160
> > 
> > 
> > > 
> > > 3. We have increased the response time of our backend (ip ended
> > > with
> > > '182') in order to exhaust the strict/lax pool. When this
> > > happens 
> > > the pool starts to throw a DeadlineTimeoutException. At this
> > > moment 
> > > the number of sockets in TIME_WAIT increases a lot until making
> > > the 
> > > server unresponsive (probably exhausting the local ports):
> > > 
> > >  [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep
> > > "179.182"
> > > > 
> > > 
> > > wc -l
> > > 99
> > > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep
> > > "179.182"
> > > > 
> > > 
> > > wc -l
> > > 101
> > > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep
> > > "179.182"
> > > > 
> > > 
> > > wc -l
> > > 98
> > > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep
> > > "179.182"
> > > > 
> > > 
> > > wc -l
> > > 25876
> > > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep
> > > "179.182"
> > > > 
> > > 
> > > wc -l
> > > 61507
> > > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep
> > > "179.182"
> > > > 
> > > 
> > > wc -l
> > > 97615
> > > 
> > > Is this the right behaviour? If Http5 cannot create new
> > > connections, 
> > > so no new sockets are opened, why does the number of sockets in 
> > > TIME_WAIT raise at those values?
> > > 
> > 
> > I believe it is. There is pretty good explanation of what the 
> > TIME_WAIT state represents in our old wiki:
> > 
> > 
> 
> 
https://wiki.apache.org/HttpComponents/FrequentlyAskedConnectionManagementQuestions
> > 
> > Oleg
> > 
> > 
> > 
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: 
> > httpclient-users-help@hc.apache.org
> > 
> > 
> > 
> > 
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: 
> > httpclient-users-help@hc.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


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


RE: RV: Migration from Async 4.1.3 to HttpClient 5

Posted by Joan Balagueró <jo...@grupoventus.com>.
Ok, so if I have a defaultMaxPerRoute = 1, and all requests I'm sending are using plain http to the same ip (without proxy) and only using 4 different ports  (8080, 8081, 8082, 8083), than this means I have 1 max connection for ip:8080, 1 for ip:8081, 1 for ip:80802 and 1 for ip:80803?
Joan.

-----Mensaje original-----
De: Oleg Kalnichevski [mailto:olegk@apache.org] 
Enviado el: viernes, 9 de noviembre de 2018 15:01
Para: HttpClient User Discussion
Asunto: Re: RV: Migration from Async 4.1.3 to HttpClient 5

On Fri, 2018-11-09 at 13:39 +0100, Joan Balagueró wrote:
> Thanks Oleg. One more thing about the max connections with lax/strict 
> pool. Our code to modify the number of max connections is:
> 
> public void setMaxConnections(int maxConnections)  {
>   this.phccm.setMaxTotal(maxConnections);
>   this.phccm.setDefaultMaxPerRoute(maxConnections);
> }
> 
> If I modify (on the fly) the max connections in a strict pool it 
> works. For example I set a very low value and I start to receive 
> DeadlineTimeoutException, when I set a higher value the error 
> disappears. If I print the pool.getMaxTotal() I get the right value.
> 
> But this does not work with a lax pool. I set up a lax pool with max 
> connections = 1, and no DeadlineTimeoutException is thrown (with the 
> same load). When I print the maxTotal and defaultMaxPerRoute I get 0 
> and 1 (instead of 1 and 1).
> 
> Is this a bug or am I missing something?
> 

Max total is not enforced by the lax pool, only max per route.

Oleg


> Thanks,
> 
> Joan.
> 
> 
> -----Mensaje original-----
> De: Oleg Kalnichevski [mailto:olegk@apache.org] Enviado el: jueves, 8 
> de noviembre de 2018 11:04
> Para: HttpClient User Discussion
> Asunto: Re: RV: Migration from Async 4.1.3 to HttpClient 5
> 
> On Wed, 2018-11-07 at 19:30 +0100, Joan Balagueró wrote:
> > Hello Oleg,
> > 
> > We are finishing the migration and have the last questions:
> > 
> > 1. If a connection is kept-alive for 30s at second 0, and after 10s 
> > is reused, this connection will die at second 30 or will survive 
> > until second 40?
> 
> Keep-alive value is always relative to the last connection release.
> If you want to limit the absolute connection life time please use set 
> a finite TTL (total time to live) value.
> 
> > 
> > 2. Regarding the RetryHandler, below the method inherited from http
> > 4.5 and modified to work with http5:
> > 
> 
> I would recommend using DefaultHttpRequestRetryHandler shipped with 
> the library unless you have some application specific requirements.
> 
> 
https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160
> 
> > public boolean retryRequest(HttpRequest request, IOException 
> > exception, int executionCount, HttpContext context) {
> >   // Don't retry if max retries are reached.
> >   if (executionCount > this.maxExecutionCount) return false;
> > 
> >   // Don't retry if any of these exceptions occur.
> >   if (exception instanceof InterruptedIOException || exception 
> > instanceof UnknownHostException || exception instanceof 
> > ConnectException || exception instanceof SSLException) return false;
> > 
> >   // Retry of if this request is considered 'idempotent'.
> >   return (!(request instanceof HttpEntityEnclosingRequest)); }
> > 
> > I understand the first two conditions are still ok (not sure if we 
> > have to add new exceptions on that list) but regarding the last 
> > condition,what would the equivalent condition be in Http5?
> > 
> 
> I would suggest the following:
> 
> 
https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160
> 
> 
> > 
> > 3. We have increased the response time of our backend (ip ended with
> > '182') in order to exhaust the strict/lax pool. When this happens 
> > the pool starts to throw a DeadlineTimeoutException. At this moment 
> > the number of sockets in TIME_WAIT increases a lot until making the 
> > server unresponsive (probably exhausting the local ports):
> > 
> >  [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 99
> > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 101
> > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 98
> > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 25876
> > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 61507
> > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 97615
> > 
> > Is this the right behaviour? If Http5 cannot create new connections, 
> > so no new sockets are opened, why does the number of sockets in 
> > TIME_WAIT raise at those values?
> > 
> 
> I believe it is. There is pretty good explanation of what the 
> TIME_WAIT state represents in our old wiki:
> 
> 
https://wiki.apache.org/HttpComponents/FrequentlyAskedConnectionManagementQuestions
> 
> Oleg
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


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




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


Re: RV: Migration from Async 4.1.3 to HttpClient 5

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2018-11-09 at 13:39 +0100, Joan Balagueró wrote:
> Thanks Oleg. One more thing about the max connections with lax/strict
> pool. Our code to modify the number of max connections is:
> 
> public void setMaxConnections(int maxConnections)
>  {
>   this.phccm.setMaxTotal(maxConnections);
>   this.phccm.setDefaultMaxPerRoute(maxConnections);
> }
> 
> If I modify (on the fly) the max connections in a strict pool it
> works. For example I set a very low value and I start to receive
> DeadlineTimeoutException, when I set a higher value the error
> disappears. If I print the pool.getMaxTotal() I get the right value.
> 
> But this does not work with a lax pool. I set up a lax pool with max
> connections = 1, and no DeadlineTimeoutException is thrown (with the
> same load). When I print the maxTotal and defaultMaxPerRoute I get 0
> and 1 (instead of 1 and 1).
> 
> Is this a bug or am I missing something?
> 

Max total is not enforced by the lax pool, only max per route.

Oleg


> Thanks,
> 
> Joan.
> 
> 
> -----Mensaje original-----
> De: Oleg Kalnichevski [mailto:olegk@apache.org] 
> Enviado el: jueves, 8 de noviembre de 2018 11:04
> Para: HttpClient User Discussion
> Asunto: Re: RV: Migration from Async 4.1.3 to HttpClient 5
> 
> On Wed, 2018-11-07 at 19:30 +0100, Joan Balagueró wrote:
> > Hello Oleg,
> > 
> > We are finishing the migration and have the last questions:
> > 
> > 1. If a connection is kept-alive for 30s at second 0, and after 10s
> > is 
> > reused, this connection will die at second 30 or will survive
> > until 
> > second 40?
> 
> Keep-alive value is always relative to the last connection release.
> If you want to limit the absolute connection life time please use set
> a finite TTL (total time to live) value. 
> 
> > 
> > 2. Regarding the RetryHandler, below the method inherited from http
> > 4.5 and modified to work with http5:
> > 
> 
> I would recommend using DefaultHttpRequestRetryHandler shipped with
> the library unless you have some application specific requirements.
> 
> 
https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160
> 
> > public boolean retryRequest(HttpRequest request, IOException 
> > exception, int executionCount, HttpContext context) {
> >   // Don't retry if max retries are reached.
> >   if (executionCount > this.maxExecutionCount) return false;
> > 
> >   // Don't retry if any of these exceptions occur.
> >   if (exception instanceof InterruptedIOException || exception 
> > instanceof UnknownHostException || exception instanceof 
> > ConnectException || exception instanceof SSLException) return
> > false;
> > 
> >   // Retry of if this request is considered 'idempotent'.
> >   return (!(request instanceof HttpEntityEnclosingRequest)); }
> > 
> > I understand the first two conditions are still ok (not sure if we 
> > have to add new exceptions on that list) but regarding the last 
> > condition,what would the equivalent condition be in Http5?
> > 
> 
> I would suggest the following:
> 
> 
https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160
> 
> 
> > 
> > 3. We have increased the response time of our backend (ip ended
> > with
> > '182') in order to exhaust the strict/lax pool. When this happens
> > the 
> > pool starts to throw a DeadlineTimeoutException. At this moment
> > the 
> > number of sockets in TIME_WAIT increases a lot until making the
> > server 
> > unresponsive (probably exhausting the local ports):
> > 
> >  [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 99
> > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 101
> > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 98
> > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 25876
> > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 61507
> > [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182"
> > | 
> > wc -l
> > 97615
> > 
> > Is this the right behaviour? If Http5 cannot create new
> > connections, 
> > so no new sockets are opened, why does the number of sockets in 
> > TIME_WAIT raise at those values?
> > 
> 
> I believe it is. There is pretty good explanation of what the
> TIME_WAIT state represents in our old wiki: 
> 
> 
https://wiki.apache.org/HttpComponents/FrequentlyAskedConnectionManagementQuestions
> 
> Oleg
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


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


RE: RV: Migration from Async 4.1.3 to HttpClient 5

Posted by Joan Balagueró <jo...@grupoventus.com>.
Thanks Oleg. One more thing about the max connections with lax/strict pool. Our code to modify the number of max connections is:

public void setMaxConnections(int maxConnections)
 {
  this.phccm.setMaxTotal(maxConnections);
  this.phccm.setDefaultMaxPerRoute(maxConnections);
}

If I modify (on the fly) the max connections in a strict pool it works. For example I set a very low value and I start to receive DeadlineTimeoutException, when I set a higher value the error disappears. If I print the pool.getMaxTotal() I get the right value.

But this does not work with a lax pool. I set up a lax pool with max connections = 1, and no DeadlineTimeoutException is thrown (with the same load). When I print the maxTotal and defaultMaxPerRoute I get 0 and 1 (instead of 1 and 1).

Is this a bug or am I missing something?

Thanks,

Joan.


-----Mensaje original-----
De: Oleg Kalnichevski [mailto:olegk@apache.org] 
Enviado el: jueves, 8 de noviembre de 2018 11:04
Para: HttpClient User Discussion
Asunto: Re: RV: Migration from Async 4.1.3 to HttpClient 5

On Wed, 2018-11-07 at 19:30 +0100, Joan Balagueró wrote:
> Hello Oleg,
> 
> We are finishing the migration and have the last questions:
> 
> 1. If a connection is kept-alive for 30s at second 0, and after 10s is 
> reused, this connection will die at second 30 or will survive until 
> second 40?

Keep-alive value is always relative to the last connection release. If you want to limit the absolute connection life time please use set a finite TTL (total time to live) value. 

> 
> 2. Regarding the RetryHandler, below the method inherited from http
> 4.5 and modified to work with http5:
> 

I would recommend using DefaultHttpRequestRetryHandler shipped with the library unless you have some application specific requirements.

https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160

> public boolean retryRequest(HttpRequest request, IOException 
> exception, int executionCount, HttpContext context) {
>   // Don't retry if max retries are reached.
>   if (executionCount > this.maxExecutionCount) return false;
> 
>   // Don't retry if any of these exceptions occur.
>   if (exception instanceof InterruptedIOException || exception 
> instanceof UnknownHostException || exception instanceof 
> ConnectException || exception instanceof SSLException) return false;
> 
>   // Retry of if this request is considered 'idempotent'.
>   return (!(request instanceof HttpEntityEnclosingRequest)); }
> 
> I understand the first two conditions are still ok (not sure if we 
> have to add new exceptions on that list) but regarding the last 
> condition,what would the equivalent condition be in Http5?
> 

I would suggest the following:

https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160


> 
> 3. We have increased the response time of our backend (ip ended with
> '182') in order to exhaust the strict/lax pool. When this happens the 
> pool starts to throw a DeadlineTimeoutException. At this moment the 
> number of sockets in TIME_WAIT increases a lot until making the server 
> unresponsive (probably exhausting the local ports):
> 
>  [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | 
> wc -l
> 99
> [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | 
> wc -l
> 101
> [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | 
> wc -l
> 98
> [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | 
> wc -l
> 25876
> [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | 
> wc -l
> 61507
> [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | 
> wc -l
> 97615
> 
> Is this the right behaviour? If Http5 cannot create new connections, 
> so no new sockets are opened, why does the number of sockets in 
> TIME_WAIT raise at those values?
> 

I believe it is. There is pretty good explanation of what the TIME_WAIT state represents in our old wiki: 

https://wiki.apache.org/HttpComponents/FrequentlyAskedConnectionManagementQuestions

Oleg



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




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


Re: RV: Migration from Async 4.1.3 to HttpClient 5

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2018-11-07 at 19:30 +0100, Joan Balagueró wrote:
> Hello Oleg,
> 
> We are finishing the migration and have the last questions:
> 
> 1. If a connection is kept-alive for 30s at second 0, and after 10s
> is reused, this connection will die at second 30 or will survive
> until second 40?

Keep-alive value is always relative to the last connection release. If
you want to limit the absolute connection life time please use set a
finite TTL (total time to live) value. 

> 
> 2. Regarding the RetryHandler, below the method inherited from http
> 4.5 and modified to work with http5:
> 

I would recommend using DefaultHttpRequestRetryHandler shipped with the
library unless you have some application specific requirements.

https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160

> public boolean retryRequest(HttpRequest request, IOException
> exception, int executionCount, HttpContext context)  
> {
>   // Don't retry if max retries are reached.
>   if (executionCount > this.maxExecutionCount) return false;
> 
>   // Don't retry if any of these exceptions occur.
>   if (exception instanceof InterruptedIOException || exception
> instanceof UnknownHostException || exception instanceof
> ConnectException || exception instanceof SSLException) return false;
> 
>   // Retry of if this request is considered 'idempotent'.
>   return (!(request instanceof HttpEntityEnclosingRequest));  
> }
> 
> I understand the first two conditions are still ok (not sure if we
> have to add new exceptions on that list) but regarding the last
> condition,what would the equivalent condition be in Http5?
> 

I would suggest the following:

https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java#L160


> 
> 3. We have increased the response time of our backend (ip ended with
> '182') in order to exhaust the strict/lax pool. When this happens the
> pool starts to throw a DeadlineTimeoutException. At this moment the
> number of sockets in TIME_WAIT increases a lot until making the
> server unresponsive (probably exhausting the local ports):
> 
>  [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" |
> wc -l
> 99
> [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" |
> wc -l
> 101
> [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" |
> wc -l
> 98
> [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" |
> wc -l
> 25876
> [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" |
> wc -l
> 61507
> [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" |
> wc -l
> 97615
> 
> Is this the right behaviour? If Http5 cannot create new connections,
> so no new sockets are opened, why does the number of sockets in
> TIME_WAIT raise at those values?
> 

I believe it is. There is pretty good explanation of what the TIME_WAIT
state represents in our old wiki: 

https://wiki.apache.org/HttpComponents/FrequentlyAskedConnectionManagementQuestions

Oleg



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


RV: Migration from Async 4.1.3 to HttpClient 5

Posted by Joan Balagueró <jo...@grupoventus.com>.
Hello Oleg,

We are finishing the migration and have the last questions:

1. If a connection is kept-alive for 30s at second 0, and after 10s is reused, this connection will die at second 30 or will survive until second 40?

2. Regarding the RetryHandler, below the method inherited from http 4.5 and modified to work with http5:

public boolean retryRequest(HttpRequest request, IOException exception, int executionCount, HttpContext context)  
{
  // Don't retry if max retries are reached.
  if (executionCount > this.maxExecutionCount) return false;

  // Don't retry if any of these exceptions occur.
  if (exception instanceof InterruptedIOException || exception instanceof UnknownHostException || exception instanceof ConnectException || exception instanceof SSLException) return false;

  // Retry of if this request is considered 'idempotent'.
  return (!(request instanceof HttpEntityEnclosingRequest));  
}

I understand the first two conditions are still ok (not sure if we have to add new exceptions on that list) but regarding the last condition,what would the equivalent condition be in Http5?


3. We have increased the response time of our backend (ip ended with '182') in order to exhaust the strict/lax pool. When this happens the pool starts to throw a DeadlineTimeoutException. At this moment the number of sockets in TIME_WAIT increases a lot until making the server unresponsive (probably exhausting the local ports):

 [root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | wc -l
99
[root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | wc -l
101
[root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | wc -l
98
[root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | wc -l
25876
[root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | wc -l
61507
[root@ns3103538 ~]# netstat -anp | grep TIME_WAIT | grep "179.182" | wc -l
97615

Is this the right behaviour? If Http5 cannot create new connections, so no new sockets are opened, why does the number of sockets in TIME_WAIT raise at those values?


Thanks,

Joan.


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


RE: Migration from Async 4.1.3 to HttpClient 5

Posted by Joan Balagueró <jo...@grupoventus.com>.
Hi Oleg,

Thanks! I'll try it asap

Joan.

-----Mensaje original-----
De: Oleg Kalnichevski [mailto:olegk@apache.org] 
Enviado el: martes, 23 de octubre de 2018 9:28
Para: HttpClient User Discussion
Asunto: Re: Migration from Async 4.1.3 to HttpClient 5

On Mon, 2018-10-22 at 20:40 +0200, Joan Balagueró wrote:
> That would be great.
> Thanks Oleg.


Hi Joan

I added #responseTimeout to RequestConfig that will work the same way as socket timeout in 4.1 for HTTP/1.1 transport 

https://github.com/apache/httpcomponents-client/commit/75ca519314b783ba0d314e84f3a7e3488a7c968c

Oleg

> 
> -----Mensaje original-----
> De: Oleg Kalnichevski [mailto:olegk@apache.org] Enviado el: domingo, 
> 21 de octubre de 2018 13:11
> Para: HttpClient User Discussion
> Asunto: Re: Migration from Async 4.1.3 to HttpClient 5
> 
> On Sat, 2018-10-20 at 20:23 +0200, Joan Balagueró wrote:
> > Ok, I understand whtat you mean. Since this is a non-blocking model 
> > when we send the request the thread is released, so I simply have to 
> > count the time passed from I send the response until the 
> > 'responseReceived' method is invoked, and if this time has been 
> > exceeded just throw an exception (and avoid read the response body 
> > content).
> > 
> > Thanks,
> > Joan.
> > 
> 
> Hi Joan
> 
> That will likely require an observer thread and creating a thread per 
> request can be expensive.
> 
> I will see if there is a way provide a socket timeout per request 
> setting for HTTP/1.1 transport only without exposing the same setting 
> to HTTP/2 transport.
> 
> Oleg
> 
> -----Mensaje original-----
> > De: Oleg Kalnichevski [mailto:olegk@apache.org] Enviado el: sábado,
> > 20
> > de octubre de 2018 18:17
> > Para: HttpClient User Discussion
> > Asunto: Re: Migration from Async 4.1.3 to HttpClient 5
> > 
> > On Fri, 2018-10-19 at 21:07 +0200, Joan Balagueró wrote:
> > > Hello Oleg,
> > > 
> > > I think it's a bit more complicated ... Let me explain it:
> > > 
> > > - we have a pool with a response timeout of 15s
> > > - this pool is shared by 2 webservices, ws1 and ws2. Ws1 uses the 
> > > pool's response timeout, but ws2 uses its own response timeout of 
> > > 10s.
> > > - the webservice ws2 has 2 methods, m1 and m2, m1 uses the ws2 
> > > timeout but m2 uses its own response timeout of 12s.
> > > - and finally the method m2 is used by 2 clients, c1 and c2. c1 is 
> > > a very good client so his response timeout is 20s, and c2 is very 
> > > bad so he only has a 3s response timeout.
> > > 
> > > When we set the response timeout at request level, we do this:
> > > 
> > > /**
> > >   * This method sets the 'responseTimeout' to this http method.
> > >   * 
> > >   * @param 		RequestBuilder		the
> > > 'RequestBuilder'
> > > object
> > >   * @param 		responseTimeout		the
> > > response
> > > timeout
> > > to apply
> > >   * @return 		none
> > >  */
> > >  private void setTimeout(RequestBuilder rb)  {
> > >   // 1. If the client has a timeout (clientResponseTimeout != -1), 
> > > then set this value
> > >   // 2. If the client has no timeout but the method has, then set 
> > > this value.
> > >   // 3. If the method has no timeout but the api has, then set 
> > > this value.
> > >   // 4. Otherwise set the pool's response timeout.
> > >   int clientResponseTimeout =
> > > this.objClient.getResponseTimeout(this.objCall.getId());
> > >   int responseTimeout =  (clientResponseTimeout != -1 ?
> > > clientResponseTimeout : (this.objCall.getResponseTimeout() != -1 ?
> > > this.objCall.getResponseTimeout() :
> > > (this.objInterface.getResponseTimeout() != -1 ?
> > > this.objInterface.getResponseTimeout() :
> > > this.objHttp.getResponseTimeout())) );
> > >  
> > > rb.setConfig(RequestConfig.copy(this.objHttp.getRequestConfig()).
> > > se
> > > tS
> > > ocketTimeout(responseTimeout).build());
> > >  }
> > > 
> > > And that's my problem now. Do you think this can be solved in any 
> > > way using http5?
> > > 
> > 
> > I must admit I do not understand the reason for doing all that in 
> > the first place. I also do not understand what exactly you mean by 
> > response timeout. Max waiting time until a response head is 
> > received?
> > 
> > Oleg
> > 
> > 
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: 
> > httpclient-users-help@hc.apache.org
> > 
> > 
> > 
> > 
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: 
> > httpclient-users-help@hc.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


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




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


Re: Migration from Async 4.1.3 to HttpClient 5

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2018-10-22 at 20:40 +0200, Joan Balagueró wrote:
> That would be great.
> Thanks Oleg.


Hi Joan

I added #responseTimeout to RequestConfig that will work the same way
as socket timeout in 4.1 for HTTP/1.1 transport 

https://github.com/apache/httpcomponents-client/commit/75ca519314b783ba0d314e84f3a7e3488a7c968c

Oleg

> 
> -----Mensaje original-----
> De: Oleg Kalnichevski [mailto:olegk@apache.org] 
> Enviado el: domingo, 21 de octubre de 2018 13:11
> Para: HttpClient User Discussion
> Asunto: Re: Migration from Async 4.1.3 to HttpClient 5
> 
> On Sat, 2018-10-20 at 20:23 +0200, Joan Balagueró wrote:
> > Ok, I understand whtat you mean. Since this is a non-blocking
> > model 
> > when we send the request the thread is released, so I simply have
> > to 
> > count the time passed from I send the response until the 
> > 'responseReceived' method is invoked, and if this time has been 
> > exceeded just throw an exception (and avoid read the response body 
> > content).
> > 
> > Thanks,
> > Joan.
> > 
> 
> Hi Joan
> 
> That will likely require an observer thread and creating a thread per
> request can be expensive. 
> 
> I will see if there is a way provide a socket timeout per request
> setting for HTTP/1.1 transport only without exposing the same setting
> to HTTP/2 transport.
> 
> Oleg
> 
> -----Mensaje original-----
> > De: Oleg Kalnichevski [mailto:olegk@apache.org] Enviado el: sábado,
> > 20 
> > de octubre de 2018 18:17
> > Para: HttpClient User Discussion
> > Asunto: Re: Migration from Async 4.1.3 to HttpClient 5
> > 
> > On Fri, 2018-10-19 at 21:07 +0200, Joan Balagueró wrote:
> > > Hello Oleg,
> > > 
> > > I think it's a bit more complicated ... Let me explain it:
> > > 
> > > - we have a pool with a response timeout of 15s
> > > - this pool is shared by 2 webservices, ws1 and ws2. Ws1 uses
> > > the 
> > > pool's response timeout, but ws2 uses its own response timeout
> > > of 
> > > 10s.
> > > - the webservice ws2 has 2 methods, m1 and m2, m1 uses the ws2 
> > > timeout but m2 uses its own response timeout of 12s.
> > > - and finally the method m2 is used by 2 clients, c1 and c2. c1
> > > is a 
> > > very good client so his response timeout is 20s, and c2 is very
> > > bad 
> > > so he only has a 3s response timeout.
> > > 
> > > When we set the response timeout at request level, we do this:
> > > 
> > > /**
> > >   * This method sets the 'responseTimeout' to this http method.
> > >   * 
> > >   * @param 		RequestBuilder		the
> > > 'RequestBuilder'
> > > object
> > >   * @param 		responseTimeout		the
> > > response
> > > timeout
> > > to apply
> > >   * @return 		none
> > >  */
> > >  private void setTimeout(RequestBuilder rb)  {
> > >   // 1. If the client has a timeout (clientResponseTimeout !=
> > > -1), 
> > > then set this value
> > >   // 2. If the client has no timeout but the method has, then
> > > set 
> > > this value.
> > >   // 3. If the method has no timeout but the api has, then set
> > > this 
> > > value.
> > >   // 4. Otherwise set the pool's response timeout.
> > >   int clientResponseTimeout =
> > > this.objClient.getResponseTimeout(this.objCall.getId());
> > >   int responseTimeout =  (clientResponseTimeout != -1 ?
> > > clientResponseTimeout : (this.objCall.getResponseTimeout() != -1
> > > ?
> > > this.objCall.getResponseTimeout() :
> > > (this.objInterface.getResponseTimeout() != -1 ?
> > > this.objInterface.getResponseTimeout() :
> > > this.objHttp.getResponseTimeout())) );
> > >  
> > > rb.setConfig(RequestConfig.copy(this.objHttp.getRequestConfig()).
> > > se
> > > tS
> > > ocketTimeout(responseTimeout).build());
> > >  }
> > > 
> > > And that's my problem now. Do you think this can be solved in
> > > any 
> > > way using http5?
> > > 
> > 
> > I must admit I do not understand the reason for doing all that in
> > the 
> > first place. I also do not understand what exactly you mean by 
> > response timeout. Max waiting time until a response head is
> > received?
> > 
> > Oleg
> > 
> > 
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: 
> > httpclient-users-help@hc.apache.org
> > 
> > 
> > 
> > 
> > -----------------------------------------------------------------
> > ----
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: 
> > httpclient-users-help@hc.apache.org
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


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


RE: Migration from Async 4.1.3 to HttpClient 5

Posted by Joan Balagueró <jo...@grupoventus.com>.
That would be great.
Thanks Oleg.

-----Mensaje original-----
De: Oleg Kalnichevski [mailto:olegk@apache.org] 
Enviado el: domingo, 21 de octubre de 2018 13:11
Para: HttpClient User Discussion
Asunto: Re: Migration from Async 4.1.3 to HttpClient 5

On Sat, 2018-10-20 at 20:23 +0200, Joan Balagueró wrote:
> Ok, I understand whtat you mean. Since this is a non-blocking model 
> when we send the request the thread is released, so I simply have to 
> count the time passed from I send the response until the 
> 'responseReceived' method is invoked, and if this time has been 
> exceeded just throw an exception (and avoid read the response body 
> content).
> 
> Thanks,
> Joan.
> 

Hi Joan

That will likely require an observer thread and creating a thread per request can be expensive. 

I will see if there is a way provide a socket timeout per request setting for HTTP/1.1 transport only without exposing the same setting to HTTP/2 transport.

Oleg

-----Mensaje original-----
> De: Oleg Kalnichevski [mailto:olegk@apache.org] Enviado el: sábado, 20 
> de octubre de 2018 18:17
> Para: HttpClient User Discussion
> Asunto: Re: Migration from Async 4.1.3 to HttpClient 5
> 
> On Fri, 2018-10-19 at 21:07 +0200, Joan Balagueró wrote:
> > Hello Oleg,
> > 
> > I think it's a bit more complicated ... Let me explain it:
> > 
> > - we have a pool with a response timeout of 15s
> > - this pool is shared by 2 webservices, ws1 and ws2. Ws1 uses the 
> > pool's response timeout, but ws2 uses its own response timeout of 
> > 10s.
> > - the webservice ws2 has 2 methods, m1 and m2, m1 uses the ws2 
> > timeout but m2 uses its own response timeout of 12s.
> > - and finally the method m2 is used by 2 clients, c1 and c2. c1 is a 
> > very good client so his response timeout is 20s, and c2 is very bad 
> > so he only has a 3s response timeout.
> > 
> > When we set the response timeout at request level, we do this:
> > 
> > /**
> >   * This method sets the 'responseTimeout' to this http method.
> >   * 
> >   * @param 		RequestBuilder		the
> > 'RequestBuilder'
> > object
> >   * @param 		responseTimeout		the response
> > timeout
> > to apply
> >   * @return 		none
> >  */
> >  private void setTimeout(RequestBuilder rb)  {
> >   // 1. If the client has a timeout (clientResponseTimeout != -1), 
> > then set this value
> >   // 2. If the client has no timeout but the method has, then set 
> > this value.
> >   // 3. If the method has no timeout but the api has, then set this 
> > value.
> >   // 4. Otherwise set the pool's response timeout.
> >   int clientResponseTimeout =
> > this.objClient.getResponseTimeout(this.objCall.getId());
> >   int responseTimeout =  (clientResponseTimeout != -1 ?
> > clientResponseTimeout : (this.objCall.getResponseTimeout() != -1 ?
> > this.objCall.getResponseTimeout() :
> > (this.objInterface.getResponseTimeout() != -1 ?
> > this.objInterface.getResponseTimeout() :
> > this.objHttp.getResponseTimeout())) );
> >  
> > rb.setConfig(RequestConfig.copy(this.objHttp.getRequestConfig()).se
> > tS
> > ocketTimeout(responseTimeout).build());
> >  }
> > 
> > And that's my problem now. Do you think this can be solved in any 
> > way using http5?
> > 
> 
> I must admit I do not understand the reason for doing all that in the 
> first place. I also do not understand what exactly you mean by 
> response timeout. Max waiting time until a response head is received?
> 
> Oleg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


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




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


Re: Migration from Async 4.1.3 to HttpClient 5

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2018-10-20 at 20:23 +0200, Joan Balagueró wrote:
> Ok, I understand whtat you mean. Since this is a non-blocking model
> when we send the request the thread is released, so I simply have to
> count the time passed from I send the response until the
> 'responseReceived' method is invoked, and if this time has been
> exceeded just throw an exception (and avoid read the response body
> content).
> 
> Thanks,
> Joan.
> 

Hi Joan

That will likely require an observer thread and creating a thread per
request can be expensive. 

I will see if there is a way provide a socket timeout per request
setting for HTTP/1.1 transport only without exposing the same setting
to HTTP/2 transport.

Oleg

-----Mensaje original-----
> De: Oleg Kalnichevski [mailto:olegk@apache.org] 
> Enviado el: sábado, 20 de octubre de 2018 18:17
> Para: HttpClient User Discussion
> Asunto: Re: Migration from Async 4.1.3 to HttpClient 5
> 
> On Fri, 2018-10-19 at 21:07 +0200, Joan Balagueró wrote:
> > Hello Oleg,
> > 
> > I think it's a bit more complicated ... Let me explain it:
> > 
> > - we have a pool with a response timeout of 15s
> > - this pool is shared by 2 webservices, ws1 and ws2. Ws1 uses the 
> > pool's response timeout, but ws2 uses its own response timeout of
> > 10s.
> > - the webservice ws2 has 2 methods, m1 and m2, m1 uses the ws2
> > timeout 
> > but m2 uses its own response timeout of 12s.
> > - and finally the method m2 is used by 2 clients, c1 and c2. c1 is
> > a 
> > very good client so his response timeout is 20s, and c2 is very bad
> > so 
> > he only has a 3s response timeout.
> > 
> > When we set the response timeout at request level, we do this:
> > 
> > /**
> >   * This method sets the 'responseTimeout' to this http method.
> >   * 
> >   * @param 		RequestBuilder		the
> > 'RequestBuilder'
> > object
> >   * @param 		responseTimeout		the response
> > timeout
> > to apply
> >   * @return 		none
> >  */
> >  private void setTimeout(RequestBuilder rb)  {
> >   // 1. If the client has a timeout (clientResponseTimeout != -1), 
> > then set this value
> >   // 2. If the client has no timeout but the method has, then set
> > this 
> > value.
> >   // 3. If the method has no timeout but the api has, then set
> > this 
> > value.
> >   // 4. Otherwise set the pool's response timeout.
> >   int clientResponseTimeout =
> > this.objClient.getResponseTimeout(this.objCall.getId());
> >   int responseTimeout =  (clientResponseTimeout != -1 ?
> > clientResponseTimeout : (this.objCall.getResponseTimeout() != -1 ?
> > this.objCall.getResponseTimeout() :
> > (this.objInterface.getResponseTimeout() != -1 ?
> > this.objInterface.getResponseTimeout() :
> > this.objHttp.getResponseTimeout())) );
> >  
> > rb.setConfig(RequestConfig.copy(this.objHttp.getRequestConfig()).se
> > tS
> > ocketTimeout(responseTimeout).build());
> >  }
> > 
> > And that's my problem now. Do you think this can be solved in any
> > way 
> > using http5?
> > 
> 
> I must admit I do not understand the reason for doing all that in the
> first place. I also do not understand what exactly you mean by
> response timeout. Max waiting time until a response head is
> received?  
> 
> Oleg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


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


RE: Migration from Async 4.1.3 to HttpClient 5

Posted by Joan Balagueró <jo...@grupoventus.com>.
Ok, I understand whtat you mean. Since this is a non-blocking model when we send the request the thread is released, so I simply have to count the time passed from I send the response until the 'responseReceived' method is invoked, and if this time has been exceeded just throw an exception (and avoid read the response body content).

Thanks,
Joan.

-----Mensaje original-----
De: Oleg Kalnichevski [mailto:olegk@apache.org] 
Enviado el: sábado, 20 de octubre de 2018 18:17
Para: HttpClient User Discussion
Asunto: Re: Migration from Async 4.1.3 to HttpClient 5

On Fri, 2018-10-19 at 21:07 +0200, Joan Balagueró wrote:
> Hello Oleg,
> 
> I think it's a bit more complicated ... Let me explain it:
> 
> - we have a pool with a response timeout of 15s
> - this pool is shared by 2 webservices, ws1 and ws2. Ws1 uses the 
> pool's response timeout, but ws2 uses its own response timeout of 10s.
> - the webservice ws2 has 2 methods, m1 and m2, m1 uses the ws2 timeout 
> but m2 uses its own response timeout of 12s.
> - and finally the method m2 is used by 2 clients, c1 and c2. c1 is a 
> very good client so his response timeout is 20s, and c2 is very bad so 
> he only has a 3s response timeout.
> 
> When we set the response timeout at request level, we do this:
> 
> /**
>   * This method sets the 'responseTimeout' to this http method.
>   * 
>   * @param 		RequestBuilder		the 'RequestBuilder'
> object
>   * @param 		responseTimeout		the response timeout
> to apply
>   * @return 		none
>  */
>  private void setTimeout(RequestBuilder rb)  {
>   // 1. If the client has a timeout (clientResponseTimeout != -1), 
> then set this value
>   // 2. If the client has no timeout but the method has, then set this 
> value.
>   // 3. If the method has no timeout but the api has, then set this 
> value.
>   // 4. Otherwise set the pool's response timeout.
>   int clientResponseTimeout =
> this.objClient.getResponseTimeout(this.objCall.getId());
>   int responseTimeout =  (clientResponseTimeout != -1 ?
> clientResponseTimeout : (this.objCall.getResponseTimeout() != -1 ?
> this.objCall.getResponseTimeout() :
> (this.objInterface.getResponseTimeout() != -1 ?
> this.objInterface.getResponseTimeout() :
> this.objHttp.getResponseTimeout())) );
>  
> rb.setConfig(RequestConfig.copy(this.objHttp.getRequestConfig()).setS
> ocketTimeout(responseTimeout).build());
>  }
> 
> And that's my problem now. Do you think this can be solved in any way 
> using http5?
> 

I must admit I do not understand the reason for doing all that in the first place. I also do not understand what exactly you mean by response timeout. Max waiting time until a response head is received?  

Oleg


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




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


RE: Migration from Async 4.1.3 to HttpClient 5

Posted by Joan Balagueró <jo...@grupoventus.com>.
Hi Oleg,

I must admit I do not understand the reason for doing all that in the first place.
--> It doesn't matter, it's important for B2B integrations in tourism sector, but that's another story.

 I also do not understand what exactly you mean by response timeout. Max waiting time until a response head is received?  
--> Yes, if we have a response timeout of 15s this is the maximum time our app will wait for getting a response from the application servers once the request has been sent. And yes, this is when response headers start to arrive (and read on 'responseReceived' method).

Thanks,

Joan. 


-----Mensaje original-----
De: Oleg Kalnichevski [mailto:olegk@apache.org] 
Enviado el: sábado, 20 de octubre de 2018 18:17
Para: HttpClient User Discussion
Asunto: Re: Migration from Async 4.1.3 to HttpClient 5

On Fri, 2018-10-19 at 21:07 +0200, Joan Balagueró wrote:
> Hello Oleg,
> 
> I think it's a bit more complicated ... Let me explain it:
> 
> - we have a pool with a response timeout of 15s
> - this pool is shared by 2 webservices, ws1 and ws2. Ws1 uses the 
> pool's response timeout, but ws2 uses its own response timeout of 10s.
> - the webservice ws2 has 2 methods, m1 and m2, m1 uses the ws2 timeout 
> but m2 uses its own response timeout of 12s.
> - and finally the method m2 is used by 2 clients, c1 and c2. c1 is a 
> very good client so his response timeout is 20s, and c2 is very bad so 
> he only has a 3s response timeout.
> 
> When we set the response timeout at request level, we do this:
> 
> /**
>   * This method sets the 'responseTimeout' to this http method.
>   * 
>   * @param 		RequestBuilder		the 'RequestBuilder'
> object
>   * @param 		responseTimeout		the response timeout
> to apply
>   * @return 		none
>  */
>  private void setTimeout(RequestBuilder rb)  {
>   // 1. If the client has a timeout (clientResponseTimeout != -1), 
> then set this value
>   // 2. If the client has no timeout but the method has, then set this 
> value.
>   // 3. If the method has no timeout but the api has, then set this 
> value.
>   // 4. Otherwise set the pool's response timeout.
>   int clientResponseTimeout =
> this.objClient.getResponseTimeout(this.objCall.getId());
>   int responseTimeout =  (clientResponseTimeout != -1 ?
> clientResponseTimeout : (this.objCall.getResponseTimeout() != -1 ?
> this.objCall.getResponseTimeout() :
> (this.objInterface.getResponseTimeout() != -1 ?
> this.objInterface.getResponseTimeout() :
> this.objHttp.getResponseTimeout())) );
>  
> rb.setConfig(RequestConfig.copy(this.objHttp.getRequestConfig()).setS
> ocketTimeout(responseTimeout).build());
>  }
> 
> And that's my problem now. Do you think this can be solved in any way 
> using http5?
> 


Oleg


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




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


Re: Migration from Async 4.1.3 to HttpClient 5

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2018-10-19 at 21:07 +0200, Joan Balagueró wrote:
> Hello Oleg,
> 
> I think it's a bit more complicated ... Let me explain it:
> 
> - we have a pool with a response timeout of 15s
> - this pool is shared by 2 webservices, ws1 and ws2. Ws1 uses the
> pool's response timeout, but ws2 uses its own response timeout of
> 10s.
> - the webservice ws2 has 2 methods, m1 and m2, m1 uses the ws2
> timeout but m2 uses its own response timeout of 12s.
> - and finally the method m2 is used by 2 clients, c1 and c2. c1 is a
> very good client so his response timeout is 20s, and c2 is very bad
> so he only has a 3s response timeout.
> 
> When we set the response timeout at request level, we do this:
> 
> /**
>   * This method sets the 'responseTimeout' to this http method.
>   * 
>   * @param 		RequestBuilder		the 'RequestBuilder'
> object
>   * @param 		responseTimeout		the response timeout
> to apply
>   * @return 		none
>  */
>  private void setTimeout(RequestBuilder rb)
>  {
>   // 1. If the client has a timeout (clientResponseTimeout != -1),
> then set this value
>   // 2. If the client has no timeout but the method has, then set
> this value.
>   // 3. If the method has no timeout but the api has, then set this
> value.
>   // 4. Otherwise set the pool's response timeout.
>   int clientResponseTimeout =
> this.objClient.getResponseTimeout(this.objCall.getId());
>   int responseTimeout =  (clientResponseTimeout != -1 ?
> clientResponseTimeout : (this.objCall.getResponseTimeout() != -1 ?
> this.objCall.getResponseTimeout() :
> (this.objInterface.getResponseTimeout() != -1 ?
> this.objInterface.getResponseTimeout() :
> this.objHttp.getResponseTimeout())) );
>  
> rb.setConfig(RequestConfig.copy(this.objHttp.getRequestConfig()).setS
> ocketTimeout(responseTimeout).build());
>  }
> 
> And that's my problem now. Do you think this can be solved in any way
> using http5?
> 

I must admit I do not understand the reason for doing all that in the
first place. I also do not understand what exactly you mean by response
timeout. Max waiting time until a response head is received?  

Oleg


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


RE: Migration from Async 4.1.3 to HttpClient 5

Posted by Joan Balagueró <jo...@grupoventus.com>.
Hello Oleg,

I think it's a bit more complicated ... Let me explain it:

- we have a pool with a response timeout of 15s
- this pool is shared by 2 webservices, ws1 and ws2. Ws1 uses the pool's response timeout, but ws2 uses its own response timeout of 10s.
- the webservice ws2 has 2 methods, m1 and m2, m1 uses the ws2 timeout but m2 uses its own response timeout of 12s.
- and finally the method m2 is used by 2 clients, c1 and c2. c1 is a very good client so his response timeout is 20s, and c2 is very bad so he only has a 3s response timeout.

When we set the response timeout at request level, we do this:

/**
  * This method sets the 'responseTimeout' to this http method.
  * 
  * @param 		RequestBuilder		the 'RequestBuilder' object
  * @param 		responseTimeout		the response timeout to apply
  * @return 		none
 */
 private void setTimeout(RequestBuilder rb)
 {
  // 1. If the client has a timeout (clientResponseTimeout != -1), then set this value
  // 2. If the client has no timeout but the method has, then set this value.
  // 3. If the method has no timeout but the api has, then set this value.
  // 4. Otherwise set the pool's response timeout.
  int clientResponseTimeout = this.objClient.getResponseTimeout(this.objCall.getId());
  int responseTimeout =  (clientResponseTimeout != -1 ? clientResponseTimeout : (this.objCall.getResponseTimeout() != -1 ? this.objCall.getResponseTimeout() : (this.objInterface.getResponseTimeout() != -1 ? this.objInterface.getResponseTimeout() : this.objHttp.getResponseTimeout())) );
  rb.setConfig(RequestConfig.copy(this.objHttp.getRequestConfig()).setSocketTimeout(responseTimeout).build());
 }

And that's my problem now. Do you think this can be solved in any way using http5?

Thanks,

Joan.



-----Mensaje original-----
De: Oleg Kalnichevski [mailto:olegk@apache.org] 
Enviado el: viernes, 19 de octubre de 2018 18:22
Para: HttpClient User Discussion
Asunto: Re: Migration from Async 4.1.3 to HttpClient 5

On Fri, 2018-10-19 at 18:01 +0200, Joan Balagueró wrote:
> Hi Oleg,
> 
> Thanks a lot for all your answers. I'll work on this a bit more.
> 
> There is just one problematic thing for us. Our app is an api gateway, 
> and one important piece is the response timeouts between our app and 
> the client application servers. If fact, it's common the user changes 
> these response timeouts from the admin console.
> 
> If now they cannot change them on the fly, that means stopping the 
> http pool, recreating the ioreactor with the new timeout and starting 
> the pool again, even if this takes just several seconds is something I 
> cannot do with installations that are processing more than 15.000 
> requests per second.
> 
> The main purpose to move to HttpClient5 is the http pool with Lax Max 
> connections (PoolConcurrencyPolicy.LAX), because we were detecting 
> contention on the current pool due to the global lock. We don't need
> HTTP/2  so, from my ignorance, is there any way to use a Lax Pool with 
> http1.1 in order to get this socket timeout at request level?
> 

No, there is not. There will be no request level socket timeout override in HC 5.0 because even with HTTP/1.1 it makes no sense when messages are being pipelined. 

HC 5.0 could however provide APIs to enumerate all open connection and let their socket timeout get re-set. Feel free to raise a change request for this feature or better yet contribute it. 

Oleg



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




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


Re: Migration from Async 4.1.3 to HttpClient 5

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2018-10-19 at 18:01 +0200, Joan Balagueró wrote:
> Hi Oleg,
> 
> Thanks a lot for all your answers. I'll work on this a bit more.
> 
> There is just one problematic thing for us. Our app is an api
> gateway, and one important piece is the response timeouts between our
> app and the client application servers. If fact, it's common the user
> changes these response timeouts from the admin console.
> 
> If now they cannot change them on the fly, that means stopping the
> http pool, recreating the ioreactor with the new timeout and starting
> the pool again, even if this takes just several seconds is something
> I cannot do with installations that are processing more than 15.000
> requests per second.
> 
> The main purpose to move to HttpClient5 is the http pool with Lax Max
> connections (PoolConcurrencyPolicy.LAX), because we were detecting
> contention on the current pool due to the global lock. We don't need
> HTTP/2  so, from my ignorance, is there any way to use a Lax Pool
> with http1.1 in order to get this socket timeout at request level?
> 

No, there is not. There will be no request level socket timeout
override in HC 5.0 because even with HTTP/1.1 it makes no sense when
messages are being pipelined. 

HC 5.0 could however provide APIs to enumerate all open connection and
let their socket timeout get re-set. Feel free to raise a change
request for this feature or better yet contribute it. 

Oleg



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


RE: Migration from Async 4.1.3 to HttpClient 5

Posted by Joan Balagueró <jo...@grupoventus.com>.
Hi Oleg,

Thanks a lot for all your answers. I'll work on this a bit more.

There is just one problematic thing for us. Our app is an api gateway, and one important piece is the response timeouts between our app and the client application servers. If fact, it's common the user changes these response timeouts from the admin console.

If now they cannot change them on the fly, that means stopping the http pool, recreating the ioreactor with the new timeout and starting the pool again, even if this takes just several seconds is something I cannot do with installations that are processing more than 15.000 requests per second.

The main purpose to move to HttpClient5 is the http pool with Lax Max connections (PoolConcurrencyPolicy.LAX), because we were detecting contention on the current pool due to the global lock. We don't need HTTP/2  so, from my ignorance, is there any way to use a Lax Pool with http1.1 in order to get this socket timeout at request level?

Thanks,

Joan.

-----Mensaje original-----
De: Oleg Kalnichevski [mailto:olegk@apache.org] 
Enviado el: viernes, 19 de octubre de 2018 17:21
Para: HttpClient User Discussion
Asunto: Re: Migration from Async 4.1.3 to HttpClient 5

On Fri, 2018-10-19 at 15:08 +0200, Joan Balagueró wrote:
> Hello,
> 
>  
> 
> We are in the process of migrating to HttpClient5 from 
> AsyncClient4.1.3, and we have some quiestions:
> 
>  
> 
> 1.       this.rc =
> RequestConfig.custom().setAuthenticationEnabled(false).
> 
>  
> setConnectionRequestTimeout(Timeout.ofMillis(this.poolTimeout)).
> 
>  
> setConnectionRequestTimeout(this.poolTimeout, TimeUnit.MILLISECONDS).
> 
>  
> setConnectionTimeout(Timeout.ofMillis(this.connectionTimeout)).
> 
>  
> setConnectTimeout(this.connectionTimeout, TimeUnit.MILLISECONDS).
> 

#setConnectTimeout was left out by mistake. It got removed after 5.0-
beta1

https://github.com/apache/httpcomponents-client/commit/60571ae8fa89918518fed57bc5a9785362f9a39a

               
> 
>  
> 
> 2.       The
> PoolingAsyncClientConnectionManagerBuilder.setConnectionTimeToLive()
> is the
> keep alive to set to connections in this pool?
> 
> (similar to what we do in
> HttpAsyncClients.custom().setKeepAliveStrategy()?)
> 

PoolingAsyncClientConnectionManagerBuilder#setConnectionTimeToLive sets the _total_ time to live for any connection. No connection will be kept alive past its TTL (time to live). Keep-alive time is always incremental.

> 
> 3.       In previous AsyncClient, we set the setSocketTimeout at
> RequestConfig level, so on each request I could copy this base ‘rc’
> and
> modify the response timeout.
> 
> But this method does no longer exist in RequestConfig. Where can I set 
> the response timeout now for each request?
> 

With HTTP/2 a single request can no longer alter the socket timeout for
the connection shared with other message streams. One needs to set the
socket timeout while building HttpAsyncClient instances with
IOReactorConfig

https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java#L317

>  
> 
> 4.       I imagine the PoolConcurrencyPolicy cannot be modified after
> creating the pool …
> 

No, it cannot.

>  
> 
> 5.       Before I had this method to set buffer sizes (and modify
> them on
> the fly), getting the ConnectionConfig from the pool:
> 
>  
> 
> public void setBufferInInterface(int bufferInInterface) { 
> 
>  
> this.phccm.setDefaultConnectionConfig(ConnectionConfig.custom().setBu
> fferSiz
> e(bufferInInterface).setFragmentSizeHint(bufferInInterface).build());
>  
> 
> }
> 
>  
> 
> How can I do this now?
> 

Why would you want to modify those settings at runetime?

Oleg


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




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


Re: Migration from Async 4.1.3 to HttpClient 5

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2018-10-19 at 15:08 +0200, Joan Balagueró wrote:
> Hello,
> 
>  
> 
> We are in the process of migrating to HttpClient5 from
> AsyncClient4.1.3, and
> we have some quiestions:
> 
>  
> 
> 1.       this.rc =
> RequestConfig.custom().setAuthenticationEnabled(false).
> 
>  
> setConnectionRequestTimeout(Timeout.ofMillis(this.poolTimeout)).
> 
>  
> setConnectionRequestTimeout(this.poolTimeout, TimeUnit.MILLISECONDS).
> 
>  
> setConnectionTimeout(Timeout.ofMillis(this.connectionTimeout)).
> 
>  
> setConnectTimeout(this.connectionTimeout, TimeUnit.MILLISECONDS).
> 

#setConnectTimeout was left out by mistake. It got removed after 5.0-
beta1

https://github.com/apache/httpcomponents-client/commit/60571ae8fa89918518fed57bc5a9785362f9a39a

               
> 
>  
> 
> 2.       The
> PoolingAsyncClientConnectionManagerBuilder.setConnectionTimeToLive()
> is the
> keep alive to set to connections in this pool?
> 
> (similar to what we do in
> HttpAsyncClients.custom().setKeepAliveStrategy()?)
> 

PoolingAsyncClientConnectionManagerBuilder#setConnectionTimeToLive sets
the _total_ time to live for any connection. No connection will be kept
alive past its TTL (time to live). Keep-alive time is always
incremental.

> 
> 3.       In previous AsyncClient, we set the setSocketTimeout at
> RequestConfig level, so on each request I could copy this base ‘rc’
> and
> modify the response timeout.
> 
> But this method does no longer exist in RequestConfig. Where can I
> set the
> response timeout now for each request?
> 

With HTTP/2 a single request can no longer alter the socket timeout for
the connection shared with other message streams. One needs to set the
socket timeout while building HttpAsyncClient instances with
IOReactorConfig

https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java#L317

>  
> 
> 4.       I imagine the PoolConcurrencyPolicy cannot be modified after
> creating the pool …
> 

No, it cannot.

>  
> 
> 5.       Before I had this method to set buffer sizes (and modify
> them on
> the fly), getting the ConnectionConfig from the pool:
> 
>  
> 
> public void setBufferInInterface(int bufferInInterface) { 
> 
>  
> this.phccm.setDefaultConnectionConfig(ConnectionConfig.custom().setBu
> fferSiz
> e(bufferInInterface).setFragmentSizeHint(bufferInInterface).build());
>  
> 
> }
> 
>  
> 
> How can I do this now?
> 

Why would you want to modify those settings at runetime?

Oleg


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