Client Connection is not timeout after specified time

이희승 (Trustin Lee) trustin at gmail.com
Thu Aug 11 23:38:15 EDT 2011


> bootstrap.setOption("connectTimeoutMillis", 100);

You set the timeout to 100 milliseconds, which is too short.

> connectFuture.awaitUninterruptibly(10,TimeUnit.SECONDS);

You have to do the following instead:

 connectFuture.awaitUninterruptibly();

The timeout you specified with awaitUninterruptibly() is not a connect timeout but how long you are going to wait for connect timeout. (i.e. it can return before connection attempt actually times out)

HTH 

-- 
Trustin Lee (http://gleamynode.net/)

On Friday, August 5, 2011 at 5:50 AM, prakash32 wrote:

> Hi,
> 
>  Am transferring beans in between client and server. i am able to sending
> and getting beans, but when server is connected not giving response for long
> time like 10 min , am not getting any connection timeout error .
>  I am setting client connection as
>  bootstrap.setOption("connectTimeoutMillis", 10000), after 10 sec
> connection is waiting for response.
> 
> And i try with ReadTimeoutHandler but still am getting problem .please
> suggest me.
> 
>  below is my client code 
> 
> 
> 
>  ClientBootstrap bootstrap = new ClientBootstrap(
>  new NioClientSocketChannelFactory(
>  Executors.newCachedThreadPool(),
>  Executors.newCachedThreadPool()));
> 
> 
>  bootstrap.setPipelineFactory(new MyPipelineFactory(requestObject));
> 
>  bootstrap.setOption("connectTimeoutMillis", 100);
> 
>  bootstrap.setOption("tcpNoDelay", true);
>  bootstrap.setOption("keepAlive", true);
>  bootstrap.setOption("reuserAddress", true);
>  ChannelFuture connectFuture = bootstrap.connect(new
> InetSocketAddress(host, port));
>  connectFuture.awaitUninterruptibly(10,TimeUnit.SECONDS);
>  Channel channel = connectFuture.getChannel();
> 
>  if (!connectFuture.isSuccess()) {
>  connectFuture.getCause().printStackTrace();
>  bootstrap.releaseExternalResources();
>  throw new RuntimeException(connectFuture.getCause());
>  }
> 
> 
>  RequestHandler handler = 
> (RequestHandler) channel.getPipeline().getLast();
> 
> 
> 
>  connectFuture.getChannel().getCloseFuture().awaitUninterruptibly();
> 
>  bootstrap.releaseExternalResources();
> 
> 
> --
> View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Client-Connection-is-not-timeout-after-specified-time-tp6654232p6654232.html
> Sent from the Netty User Group mailing list archive at Nabble.com (http://Nabble.com).
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org (mailto:netty-users at lists.jboss.org)
> https://lists.jboss.org/mailman/listinfo/netty-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20110812/43b21224/attachment.html 


More information about the netty-users mailing list