Sample how to using TimeOut
Christian Migowski
chrismfwrd at gmail.com
Mon Jul 27 01:19:25 EDT 2009
Hi Reza,
you maybe already figured it out by yourself:
The connectTimeout only applies to connect, ie. after which time the
Future returned from a connect(...) call will indicate that the
attempt was not successful (if the connection could not be
established).
If you want to have IdleStateEvents, you need to have an
org.jboss.netty.handler.timeout.IdleStateHandler in your pipeline
(This is different to Mina, where this idleness detection was part of
the default active functionality).
regards,
christian!
On Fri, Jul 24, 2009 at 3:03 PM, Syahreza Pahlevi
Ginting<rezaginting at gmail.com> wrote:
> Dear All,
> Did any one have implement Timeout, could you share to me, because i have
> failed to implement.
> IdleStateEvent never raised in function handleUpstream;
> Sample of my code :
> Server Side
> log.info("Start listening on " + ip + ":" + port);
> ChannelFactory factory =
> new NioServerSocketChannelFactory(
> Executors.newCachedThreadPool(),
> Executors.newCachedThreadPool());
>
> ServerBootstrap bootstrap = new ServerBootstrap(factory);
>
> bootstrap.setPipelineFactory(new ConnPipelineFactory(this));
> bootstrap.setOption("child.tcpNoDelay", true);
> bootstrap.setOption("child.keepAlive", true);
> bootstrap.setOption("child.reuseAddress", true);
> bootstrap.setOption("child.connectTimeoutMillis", 10000);
>
> // Bind and start to accept incoming connections.
> InetAddress inet = InetAddress.getByName(ip);
> bootstrap.bind(new InetSocketAddress(inet,port));
> log.info("Finish listening on " + ip + ":" + port);
>
>
> Client Side :
> ChannelFactory factory = new NioClientSocketChannelFactory(
> Executors.newCachedThreadPool(),
> Executors.newCachedThreadPool());
> ClientBootstrap bootstrap = new ClientBootstrap(factory);
> bootstrap.setPipelineFactory(new ConnPipelineFactory(this));
> bootstrap.setOption("tcpNoDelay", true);
> bootstrap.setOption("keepAlive", true);
> bootstrap.setOption("reuseAddress", true);
> bootstrap.setOption("connectTimeoutMillis", 1000);
>
> Trims
>
> Reza Ginting
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
>
More information about the netty-users
mailing list