title: How can I forward a message that received a server to another server in Netty (Java)?
body: <p>I have some clients, they communicate with one server and I need that server forward the message to another second server. Then, receive the message from the second server and send to the client.</p>
  
  <p>With this method, I achieve connecting to the second server but it doesn't receive the message and throws me the following exception:</p>
  
  <p>EXCEPTION: java.nio.channels.NotYetConnectedException. java.nio.channels.NotYetConnectedException</p>
  
  <pre><code>public void messageReceived(ChannelHandlerContext ctx, final MessageEvent e) throws IOException, Exception {
          response = "hola" + "\r\n";
          Main.creaLog("Mensaje recibido del conc: " + e.getMessage().toString());
          Main.creaLog("Mensaje enviado al servidor : " + response);
  
  
          ClientBootstrap bootstrap1 = new ClientBootstrap(
          new NioClientSocketChannelFactory(
              Executors.newCachedThreadPool(),
              Executors.newCachedThreadPool()));
  
          // Configure the pipeline factory.
          //bootstrap1.setPipelineFactory(new CLIENTE.ClientePipelineFactory());
          bootstrap1.setPipelineFactory(new ChannelPipelineFactory() {
           public ChannelPipeline getPipeline() {
                  return Channels.pipeline(new ClienteHandler());
           }
          });
  
          final ChannelFuture future = bootstrap1.connect(new InetSocketAddress("172.16.10.14", 12355));
  
          Channel channel = future.getChannel();
  
          if (channel.isWritable()) {
              ChannelFuture lastWriteFuture = channel.write(e.getMessage().toString() + "\r\n");
          }
          close = true;
  
  
      // We do not need to write a ChannelBuffer here.
      // We know the encoder inserted at TelnetPipelineFactory will do the conversion.
      ChannelFuture future = e.getChannel().write(response + "\r\n");
      //CIERRA LA CONEXION
      if (close) {
          future.addListener(ChannelFutureListener.CLOSE);
      }
  }
  </code></pre>
  
  <p>I'm very thanksful if anybody can help me.</p>