hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From whybert <whyb...@163.com>
Subject Re:Re: Re:Re: A question about ConnectTimeout and SoTimeout
Date Mon, 25 Aug 2014 14:51:43 GMT
2014/08/25 22:49:05:698 CST [DEBUG] MainClientExec - [exchange: 1] start execution
2014/08/25 22:49:05:709 CST [DEBUG] RequestAddCookies - CookieSpec selected: best-match
2014/08/25 22:49:05:719 CST [DEBUG] RequestAuthCache - Auth cache not set in the context
2014/08/25 22:49:05:719 CST [DEBUG] InternalHttpAsyncClient - [exchange: 1] Request connection
for {}->http://1.1.1.1:80
2014/08/25 22:49:05:721 CST [DEBUG] PoolingNHttpClientConnectionManager - Connection request:
[route: {}->http://1.1.1.1:80][total kept alive: 0; route allocated: 0 of 2; total allocated:
0 of 20]
2014/08/25 22:49:26:729 CST [DEBUG] PoolingNHttpClientConnectionManager - Connection request
failed <java.net.ConnectException: Connection timed out: no further information>java.net.ConnectException:
Connection timed out: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:173)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:147)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:189)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.doExecute(CloseableHttpAsyncClientBase.java:67)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.access$000(CloseableHttpAsyncClientBase.java:38)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:57)
at java.lang.Thread.run(Unknown Source)


2014/08/25 22:49:26:731 CST [DEBUG] InternalHttpAsyncClient - [exchange: 1] connection request
failed
2014/08/25 22:49:26:732 CST [DEBUG] PoolingNHttpClientConnectionManager - Connection manager
is shutting down
2014/08/25 22:49:26:737 CST [DEBUG] PoolingNHttpClientConnectionManager - Connection manager
shut down
21008
java.net.ConnectException: Connection timed out: no further information




Whybert



At 2014-08-25 10:19:21, "Oleg Kalnichevski" <olegk@apache.org> wrote:
>On Mon, 2014-08-25 at 20:13 +0800, whybert wrote:
>> Thank you for your reply.
>> 
>> 
>> I think I just set the IOReactorConfig.setConnectTimeout(). This is my code (HttpAsyncClient4.0.2)
:
>> 
>> 
>> public class Test {
>>     public static void main(String[] args) throws InterruptedException,
>>             IOException, TimeoutException {
>>         IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
>>                 .setConnectTimeout(2000).build();
>>         ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(
>>                 ioReactorConfig);
>>         PoolingNHttpClientConnectionManager cm = new PoolingNHttpClientConnectionManager(
>>                 ioReactor);
>>         CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
>>                 .setConnectionManager(cm).build();
>>         httpclient.start();
>>         HttpGet request = new HttpGet("http://1.1.1.1/");
>>         Future<HttpResponse> future = httpclient.execute(request, null);
>>         long timeSt = new Date().getTime();
>>         try {
>>             HttpResponse response = future.get();
>>         } catch (InterruptedException e) {
>>             e.printStackTrace();
>>         } catch (ExecutionException e) {
>>             System.out.println(new Date().getTime() - timeSt);
>>             System.out.println(e.getMessage());
>>         }
>>         httpclient.close();
>>     }
>> }
>> 
>> 
>> It took 21 seconds to get a ConnectException while the ConnectTimeout was 2 seconds.

>> Could you help me to look at this problem? Thanks!
>> 
>
>Whybert
>
>Please post a wire / context log of the session.
>
>http://hc.apache.org/httpcomponents-client-4.3.x/logging.html
>
>Oleg
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message