[prev in list] [next in list] [prev in thread] [next in thread] 

List:       httpclient-users
Subject:    Re: NoHttpResponseException
From:       Oleg Kalnichevski <olegk () apache ! org>
Date:       2015-02-18 9:28:12
Message-ID: 1424251692.32298.1.camel () apache ! org
[Download RAW message or body]

On Tue, 2015-02-17 at 12:20 +0100, Joan Balagueró wrote:
> Hello,
> 
>  
> 
> I ’m occassionally getting the following error (HC 4.3.4)
> 
>  
> 
> There was no reply from the server
> org.apache.http.NoHttpResponseException: 10.150.3.159:80 failed to respond
> 
>         at
> org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpRes
> ponseParser.java:143)
> 
>         at
> org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpRes
> ponseParser.java:57)
> 
>         at
> org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.ja
> va:260)
> 
>         at
> org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(Defa
> ultBHttpClientConnection.java:161)
> 
>         at
> org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:1
> 53)
> 
>         at
> org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestEx
> ecutor.java:271)
> 
>         at
> org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.jav
> a:123)
> 
>         at
> org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:25
> 4)
> 
>         at
> org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
> 
>         at
> org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
> 
>         at
> org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.
> java:184)
> 
>         at
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.
> java:82)
> 
>         at
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.
> java:106)
> 
>         at
> com.ventusproxy.proxy.services.http.HttpInstance.sendRequest(HttpInstance.ja
> va:610)
> 
>       ( . . . )
> 
>  
> 
> I ’ve read some posts about it. It seems that the main reason is that
> keep-alive connections are dropped on the server side. In my case I don ’t
> have keep alive enabled (every request initiates a new connection to the
> server). Furthermore I have the following retryHandler:
> 
>  
> 
> public class RequestRetryHandler implements HttpRequestRetryHandler 
> 
> {
> 
> private int maxExecutionCount;
> 
>  
> 
> public RequestRetryHandler(int maxExecutionCount)           {
> this.setMaxExecutionCount(maxExecutionCount); }
> 
> public void setMaxExecutionCount(int maxExecutionCount) {
> this.maxExecutionCount = maxExecutionCount; }
> 
>  public boolean retryRequest(IOException exception, int executionCount,
> HttpContext context) 
> 
>  {
> 
>   if (executionCount > this.maxExecutionCount) return false;
> 
>  
> 
>   if ( (exception instanceof InterruptedIOException) || (exception
> instanceof UnknownHostException) || (exception instanceof ConnectException)
> || (exception instanceof SSLException) ) return false;
> 
>   
> 
>   return (!(HttpClientContext.adapt(context).getRequest() instanceof
> HttpEntityEnclosingRequest));
> 
> }
> 
> }
> 
>  
> 
> I realize it ’s a server problem (it ’s probably dropping connections), but is
> there anything else I can do to minimize this error (in addition to disable
> keepAlive and enable a retryHandler)?
> 

NoHttpResponseException can happen no matter what. For instance, some
servers tend to drop connections under heavy load. All you can do is
retry requests failed with NoHttpResponseException.

Oleg



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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic