A small test validates that it is indeed that I am not setting
socketTimeout.  Thanks for the help Oleg!

-Rob

On 7/28/14 4:08 AM, "Oleg Kalnichevski" <[email protected]> wrote:

>On Fri, 2014-07-25 at 16:24 +0000, Rob Burke wrote:
>> Hello,
>>
>> I have been facing issues with the HttpClient around resiliency to
>>server-side failures.   My intention is that if my Http request isn't
>>satisfied in some small amount of time (say 600ms), then HttpClient
>>should give up.
>>
>> I thought that I was achieving this by setting connectionTimeout in the
>>RequestConfig.  Today we ran into a situation where we blocked
>>indefinitely in httpClient.  I finally killed the server it was
>>connecting to, and my HttpClient requesting code (below) finally throws
>>an IOException.
>>
>>  Our logging was empty until I killed the remote server.  Once it was
>>down, the client logged:
>>
>> 10:36:15.712 [ServiceRunnerThread] INFO
>>o.a.http.impl.execchain.RetryExec - I/O exception
>>(org.apache.http.NoHttpResponseException) caught when processing request
>>to {}->http://remotehost:8888<http://remotehost:8888/>: The target
>>server failed to respond
>> 10:36:15.713 [ServiceRunnerThread] INFO
>>o.a.http.impl.execchain.RetryExec - Retrying request to
>>{}->http://remotehost:8888<http://remotehost:8888/>
>> 10:36:15.768 [ServiceRunnerThread] ERROR  c.i.g.s.b.o.m.DataService -
>>Exception while attempting to connect to Remote Gateway:
>>org.apache.http.conn.HttpHostConnectException: Connect to remote
>>host:8888 [remotehost/10.1.1.1] failed: Connection refused
>>
>>
>> Here is my request logic.  I am using httpclient-4.3.3:
>>
>>         final HttpGet myRequest = new HttpGet(aUri);
>>
>>         try {
>>             RequestConfig myRequestConfig =
>>RequestConfig.custom().setConnectTimeout(CONNECTION_TIMEOUT).build();
>>             CloseableHttpClient myClient = HttpClientBuilder.create()
>>                     .setDefaultRequestConfig(myRequestConfig)
>>                     .build();
>>             final HttpResponse myResponse =
>>myClient.execute(myRequest);
>>             final HttpEntity myEntity = myResponse.getEntity();
>>
>>             if (myEntity == null) {
>>                 return null;
>>             }
>>
>>             final String myContent = EntityUtils.toString(myEntity);
>>             if (ok(myResponse)) {
>>                 return theObjectMapper.readValue(myContent, aClass);
>>             } else {
>>                 LOGGER.error("{}", myContent);
>>                 return null;
>>             }
>>         } finally {
>>             myRequest.releaseConnection();
>>         }
>>
>>
>> I am hoping this is a simple oversight in my construction of the
>>HttpClient.
>>
>>
>> Any and all ideas/suggestions is greatly appreciated!
>>
>
>It looks like the server succeeded in accepting an incoming connection
>within the given timeout (CONNECTION_TIMEOUT) but failed to send back
>any data. Please also make sure that you set a socket (read) timeout.
>
>Oleg
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [email protected]
>For additional commands, e-mail: [email protected]
>


________________________________

The information in this e-mail is intended only for the person or entity to 
which it is addressed.

It may contain confidential and /or privileged material. If someone other than 
the intended recipient should receive this e-mail, he / she shall not be 
entitled to read, disseminate, disclose or duplicate it.

If you receive this e-mail unintentionally, please inform us immediately by 
"reply" and then delete it from your system. Although this information has been 
compiled with great care, neither IMC Financial Markets & Asset Management nor 
any of its related entities shall accept any responsibility for any errors, 
omissions or other inaccuracies in this information or for the consequences 
thereof, nor shall it be bound in any way by the contents of this e-mail or its 
attachments. In the event of incomplete or incorrect transmission, please 
return the e-mail to the sender and permanently delete this message and any 
attachments.

Messages and attachments are scanned for all known viruses. Always scan 
attachments before opening them.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to