hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Burke <Rob.Bu...@imc-chicago.com>
Subject Re: HttpClient code blocks until remote server is killed
Date Mon, 28 Jul 2014 17:26:23 GMT
A small test validates that it is indeed that I am not setting
socketTimeout.  Thanks for the help Oleg!


On 7/28/14 4:08 AM, "Oleg Kalnichevski" <olegk@apache.org> 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
>> 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/] failed: Connection refused
>> Here is my request logic.  I am using httpclient-4.3.3:
>>         final HttpGet myRequest = new HttpGet(aUri);
>>         try {
>>             RequestConfig myRequestConfig =
>>             CloseableHttpClient myClient = HttpClientBuilder.create()
>>                     .setDefaultRequestConfig(myRequestConfig)
>>                     .build();
>>             final HttpResponse myResponse =
>>             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
>> 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.
>To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>For additional commands, e-mail: httpclient-users-help@hc.apache.org


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: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message