title: Netty Handler not called
body: <p>I'm trying to get into Netty using a simple server-client application (code see below).</p>
  
  <p>I'm struggling with two issues:</p>
  
  <ol>
  <li><p>the ConfigServerHandler resp. ConfigClientHandler is called correctly. But the FeedbackServerHandler resp. FeedbackClientHandler is never called. Why? According to the documentation the Handlers should be called one after another. </p></li>
  <li><p>I'd like to have several handlers. Each of these  handlers is interested in only some of the messages that are send by the other side (e.g. send by client, received by server). </p>
  
  <ul>
  <li>should I filter the messages after they have been received by a handler (channelRead)? How can I distinguish different Strings? With different objects this should be pretty easy by parsing them. </li>
  <li>is it possible to define different ChannelPipelines for a SocketChannel? </li>
  <li>further approaches?</li>
  </ul></li>
  </ol>
  
  <p>Thanks for your help!</p>
  
  <p>KJ</p>
  
  <p>This is how the server is created:</p>
  
  <pre><code>public void run() throws Exception {
  
      EventLoopGroup bossGroup = new NioEventLoopGroup(1);
      EventLoopGroup workerGroup = new NioEventLoopGroup();
      try {
          ServerBootstrap b = new ServerBootstrap();
          b.group(bossGroup, workerGroup)
           .channel(NioServerSocketChannel.class)
           .handler(new LoggingHandler(LogLevel.INFO))
           .childHandler(new ChannelInitializer&lt;SocketChannel&gt;() {
               @Override
               public void initChannel(SocketChannel ch) throws Exception {
                   ChannelPipeline p = ch.pipeline();
                   p.addLast(
                       new ObjectEncoder(),
                       new ObjectDecoder(ClassResolvers.cacheDisabled(null)),
                       new ConfigServerHandler(),
                       new FeedbackServerHandler());
               }
           });
        b.bind(mPort).sync().channel().closeFuture().sync();
      } finally {
          bossGroup.shutdownGracefully();
          workerGroup.shutdownGracefully();
      }
  }
  </code></pre>
  
  <p>One of the Handler classes (the FeedbackServerHandler does exactly the same but parses into Integer):</p>
  
  <pre><code>public class ConfigServerHandler extends ChannelInboundHandlerAdapter {
  
      @Override
      public void channelRead(ChannelHandlerContext ctx, Object msg) {
          System.out.println("ConfigServerHandler::channelRead, " +(String)msg);
          ctx.write(msg);
      }
  
      @Override
      public void channelReadComplete(ChannelHandlerContext ctx) {
          ctx.flush();
      }
  
      @Override
      public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
          cause.printStackTrace();
          ctx.close();
     }
  }
  </code></pre>
  
  <p>The client side looks pretty similar:</p>
  
  <pre><code>public Client(String host, int port) throws InterruptedException {
  
      EventLoopGroup workerGroup = new NioEventLoopGroup();
      try {
          Bootstrap b = new Bootstrap();
          b.group(workerGroup)
           .channel(NioSocketChannel.class)
           .handler(new ChannelInitializer&lt;SocketChannel&gt;() {
               @Override
               public void initChannel(SocketChannel ch) throws Exception {
                   ChannelPipeline p = ch.pipeline();
                    p.addLast(
                        new ObjectEncoder(),
                        new ObjectDecoder(ClassResolvers.cacheDisabled(null)),
                        new ConfigClientHandler(),
                        new FeedbackClientHandler());
               }
           });
           b.connect(host, port).sync().channel().closeFuture().sync();
      } finally {
          workerGroup.shutdownGracefully();
      }
  }
  </code></pre>
  
  <p>And here is one of the Client side handlers (the other one sends an Integer message and parses into Integer in the 'channelRead' method):</p>
  
  <pre><code>public class ConfigClientHandler extends ChannelInboundHandlerAdapter {
  
      private final String firstMessage = "blubber";
  
      @Override
      public void channelActive(ChannelHandlerContext ctx) {
          System.out.println("ConfigClientHandler::channelActive");
          ctx.writeAndFlush(firstMessage);
      }
  
      @Override
      public void channelRead(ChannelHandlerContext ctx, Object msg) {
          System.out.println("ConfigClientHandler::channelRead, " +(String)msg);
          ctx.write(msg);
      }
  
      @Override
      public void channelReadComplete(ChannelHandlerContext ctx) {
          ctx.flush();
      }
  </code></pre>
  
  <p>}</p>