hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joan Balagueró <joan.balagu...@grupoventus.com>
Subject NoHttpResponseException in the async client
Date Thu, 10 Nov 2016 10:37:22 GMT

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:

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 =
  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?



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

View raw message