Sample how to using TimeOut

Syahreza Pahlevi Ginting rezaginting at gmail.com
Fri Jul 24 09:03:28 EDT 2009


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20090724/4a1a6ba7/attachment.html 


More information about the netty-users mailing list