SSL Handshake : timing and timeout

2016-11-10 Thread Philippe Mouawad
Hello,
Is there a way in HttpClient/HttpCore to compute the time taken by SSL
Handshake ?
And timeout handshake ?

Thank you
Regards
Philippe M.


Re: RetryHandler Per GetMethod

2016-11-10 Thread Murat Balkan
Hi,
So I need to put to the Context an attribute and read it in the handler?
Thank you

On 10 November 2016 at 05:38, Bernd Eckenfels 
wrote:

> In fact the retry handlers (some implementations)  already look at the
> method and only retry idempotent methods
>
> Gruss
> Bernd
> --
> http://bernd.eckenfels.net
>
>
>
>
> On Thu, Nov 10, 2016 at 11:15 AM +0100, "Oleg Kalnichevski" <
> ol...@apache.org> wrote:
>
>
>
>
>
>
>
>
>
>
> On Wed, 2016-11-09 at 09:05 -0500, Murat Balkan wrote:
> > Hello,
> >
> > Is it possible to set a retry handler per HttpGet? The following code
> taken
> > from the documentation only applies to 3x and seems to be deprecated.
> >
> >
> > httpget.getParams().
> > setParameter(HttpMethodParams.RETRY_HANDLER, myretryhandler);
> >
> >
> > What I want to achieve is to set disableAutomaticRetries on the
> httpclient
> > level and set them at the httpget level.
> >
> > Is this supported?
> >
>
> No it is not, but one can use HttpContext attributes to customize the
> handler's behavior on the per request basis.
>
> Oleg
>
>
> -
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org
>
>
>
>
>
>
>


-- 
Murat Balkan


Re: HttpClient behavior on close with active connections

2016-11-10 Thread Shawn Heisey
On 11/10/2016 3:21 AM, Oleg Kalnichevski wrote:
> On Wed, 2016-11-09 at 13:43 -0700, Shawn Heisey wrote:
>> What happens to a long-lived HTTP connection if another thread calls
>> close() on the HttpClient? Does the connection immediately die and
>> throw an exception, or would the connection finish as expected in its
>> own time? 
> Yes, it does. CloseableHttpClient#close immediately purges the
> internal pool of all connections both active (leased) and inactive
> (kept alive). HC 5.0 will support graceful shutdown option whereby one
> can give connections some grace period to complete ongoing exchanges
> prior to shutting down. 

Thank you!  I prefer to have everything shut down immediately, so this
is good news.  If the exception that happens in the background thread is
different enough from exceptions indicating "real" problems, I will be
able to detect that situation and log a short warning, instead of a full
stacktrace.  I will be on the lookout for this when I've written enough
of the code to test it.

Thanks,
Shawn


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



Re: RetryHandler Per GetMethod

2016-11-10 Thread Bernd Eckenfels
In fact the retry handlers (some implementations)  already look at the method 
and only retry idempotent methods

Gruss
Bernd
-- 
http://bernd.eckenfels.net




On Thu, Nov 10, 2016 at 11:15 AM +0100, "Oleg Kalnichevski"  
wrote:










On Wed, 2016-11-09 at 09:05 -0500, Murat Balkan wrote:
> Hello,
> 
> Is it possible to set a retry handler per HttpGet? The following code taken
> from the documentation only applies to 3x and seems to be deprecated.
> 
> 
> httpget.getParams().
> setParameter(HttpMethodParams.RETRY_HANDLER, myretryhandler);
> 
> 
> What I want to achieve is to set disableAutomaticRetries on the httpclient
> level and set them at the httpget level.
> 
> Is this supported?
> 

No it is not, but one can use HttpContext attributes to customize the
handler's behavior on the per request basis.

Oleg


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








NoHttpResponseException in the async client

2016-11-10 Thread Joan Balagueró
Hello,

We have replaced the httpclient by the async client in our application.
Everything works fine, but the ‘NoHttpResponseException’ has disappeared
from our error statistics reports. So, or with the new async pool this error
does not occur for some reason (that I don’t know) or we are not catching
this error correctly (more likely).

We are using an ‘HttpAsyncResponseConsumer’ and overwriting the
‘responseReceived’, ‘consumeContent’ and ‘failed’ methods. We
understand that when a ‘NoHttpResponseException’ occurs,
‘responseReceived’ and ‘consumeContent’ are not called, and  the
‘failed’ method is the only one that is directly called.

Our ‘failed’ method looks like this:

@Override
public void failed(final Exception e)
{
  ProxyServletException pse = null;
  
  if (e.getClass() == java.net.SocketTimeoutException.class) pse = new
ProxyServletException(ErrorConstants.HTTP_RESPONSE_TIMEOUT, e);
  else if (e.getClass() == java.net.ConnectException.class) pse = new
ProxyServletException(ErrorConstants.HTTP_CONNECT_TIMEOUT, e);
  else if (e.getClass() == org.apache.http.NoHttpResponseException.class)
pse = new ProxyServletException(ErrorConstants.HTTP_NO_RESPONSE, e);←
the error is caugth here 
  else if (e.getClass() == java.io.IOException.class) pse = new
ProxyServletException(ErrorConstants.HTTP_GENERIC_HTTP, e);
  else if (e.getClass() ==
com.ventusproxy.proxy.servlet.ProxyServletException.class) pse =
(ProxyServletException)e;
  else if (e.getClass() ==
org.apache.http.conn.ConnectionPoolTimeoutException.class) pse = new
ProxyServletException(ErrorConstants.HTTP_MAX_CONNECTIONS, e);
  else if (e.getClass() == java.util.concurrent.TimeoutException.class) pse
= new ProxyServletException(ErrorConstants.HTTP_MAX_CONNECTIONS, e);

  pse = (pse != null ? pse : new
ProxyServletException(ErrorConstants.HTTP_GENERIC_HTTP, e));

  ( . . . )
}


Is this ok? Or I'm missing something?

Thanks,

Joan.


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



Re: HttpClient behavior on close with active connections

2016-11-10 Thread Oleg Kalnichevski
On Wed, 2016-11-09 at 13:43 -0700, Shawn Heisey wrote:
> I'm using SolrJ 6.2.1 in the program I'm writing, which pulls in
> httpclient/httpmime 4.5.2 and httpcore 4.4.5 as dependencies.
> 
> One of the things that my SolrJ code does takes over an hour to
> complete.  The HTTP connection is kept open for all that time.  I'd like
> to find a way for the Solr server to respond immediately and continue
> the operation in the background, but currently there doesn't seem to be
> a way to do that.
> 
> Now I am attempting to make it possible to gracefully shut down
> everything related to what my code does, turn everything into garbage,
> reload the configuration, and build it all back up.  Therefore I need to
> know how certain things behave at close/shutdown, assuming everything is
> not idle.
> 
> What happens to a long-lived HTTP connection if another thread calls
> close() on the HttpClient?  Does the connection immediately die and
> throw an exception, or would the connection finish as expected in its
> own time? 

Hi Shawn

Yes, it does. CloseableHttpClient#close immediately purges the internal
pool of all connections both active (leased) and inactive (kept alive).
HC 5.0 will support graceful shutdown option whereby one can give
connections some grace period to complete ongoing exchanges prior to
shutting down. 
  
Hope this helps

Oleg

>  If the connection remains open until completion, does the
> close() call return immediately, or wait until that connection ends,
> whether successful or not?  Are all object references (threads in
> particular) properly released and turned into garbage?  I tried to
> follow the code, but got lost quickly.  If it's documented somewhere,
> please point me at that documentation.
> 
> Thanks,
> Shawn
> 
> 
> -
> 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: RetryHandler Per GetMethod

2016-11-10 Thread Oleg Kalnichevski
On Wed, 2016-11-09 at 09:05 -0500, Murat Balkan wrote:
> Hello,
> 
> Is it possible to set a retry handler per HttpGet? The following code taken
> from the documentation only applies to 3x and seems to be deprecated.
> 
> 
> httpget.getParams().
> setParameter(HttpMethodParams.RETRY_HANDLER, myretryhandler);
> 
> 
> What I want to achieve is to set disableAutomaticRetries on the httpclient
> level and set them at the httpget level.
> 
> Is this supported?
> 

No it is not, but one can use HttpContext attributes to customize the
handler's behavior on the per request basis.

Oleg


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



Re: NoHttpResponseException Timer?

2016-11-10 Thread Oleg Kalnichevski
On Tue, 2016-11-08 at 10:48 -0500, Murat Balkan wrote:
> Hi Oleg,
> 
> From the documentation , I understand that this exception is thrown after
> the TCP socket is opened and client sends GET / request. We then start
> waiting the response from the server, but it never responds but drops the
> connection after 50 seconds in my case (which I believe a server parameter)
> 
> My question is, shouldn't socket timeout timer kick in as soon as the
> socket is open? Does it need at least 1 packet to arrive at the client?
> 

Yes, socket (read) timeout setting should apply.

Oleg

> Thanks
> 
> On 8 November 2016 at 07:35, Oleg Kalnichevski  wrote:
> 
> > On November 7, 2016 9:16:19 PM GMT+01:00, Murat Balkan 
> > wrote:
> > >Hi,
> > >
> > >Which timer does the NoHttpResponseException use? My socket timeout is
> > >set
> > >around 30 and connection timeout is set to 20. However, I see that in
> > >some
> > >cases, this exception is thrown after more than 50 seconds.
> > >
> > >Is there a timeout for org.apache.http.NoHttpResponseException?
> > >
> > >Thanks
> > >Murat
> >
> > There is no timer. This exception is thrown if the server closes the
> > connection on its end without any response what so ever
> >
> > Oleg
> > --
> > Sent from my Android device with K-9 Mail. Please excuse my brevity.
> >
> 
> 
> 



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