2013-07-29 4 views
0

Netty를 처음 사용했습니다. 이것은 예상되는 행동입니까? Netty 4 ReadTimeoutHandler가 OioEventLoopGroup에 포함되지 않음

좀 더 자세한

:

public class Test { 
    public static void connect(){ 
    EventLoopGroup workerGroup = new NioEventLoopGroup(); 
    Bootstrap bs = new Bootstrap(); 
    bs.group(workerGroup); 
    bs.channel(NioSocketChannel.class); 
    bs.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000); 
    bs.handler(new ChannelInitializer<SocketChannel>(){ 
     @Override 
     protected void initChannel(SocketChannel ch) throws Exception { 
     ChannelPipeline pl = ch.pipeline(); 
     pl.addLast("readTimeoutHandler", new ReadTimeoutHandler(1000, 
      TimeUnit.MILLISECONDS)); 
      pl.addLast("framer", new DelimiterBasedFrameDecoder(
      16384, Delimiters.lineDelimiter())); 
      pl.addLast("string-decoder", new StringDecoder()); 
      pl.addLast("handler", 
      new SimpleChannelInboundHandler<String> (String.class){ 
       @Override 
       protected void channelRead0(ChannelHandlerContext ctx, 
       String msg) throws Exception { 
       System.out.println(msg); 
       } 
       @Override 
       protected void exceptionCaught(ChannelHandlerContext ctx, 
       Throwable cause) throws Exception { 
       if(cause instanceof ReadTimeoutException){ 
        System.out.println("Timed out."); 
       } 
       ctx.close(); 
       } 
      }); 
     } 
    }); 
    bs.connect("127.0.0.1", 45001); 
    } 
} 

이 그냥 테스트 케이스이므로 조금 잘못된, 파이프 라인하지만 내 실제 파이프 라인이 충분히 가까이 ressembles 수 있습니다.

나는 아무 것도 건드리지 않고 bootstrap.channel(NioSocketChannel.class)에서 bootstrap.channel(OioSocketChannel.class)OioEventLoopGroup 및 부트 스트랩 채널 설정에 NioEventLoopGroup에서 EventLoopGroup 초기화를 변경하는 경우 Basicly, ReadTimeoutHandler 정지가 ReadTimeoutExceptions를 던지고.

답변