I\'m new to netty and still strugling to find my way. I\'m looking to create an http client that works asynchronously. The netty examples of http only show how to wait for IO op
You are using a ChannelFutureListener to do all operations in the channel (which is bad), and the future listener will be executed right after calling those channel operations.
The problem is, After sending the message, channel is disconnected immediately and the handler can not receive the response message which comes later.
........
case Sending:
this.state = State.Disconnecting;
future.getChannel().disconnect().addListener(this);
break;
........
you should not block the channel future thread at all. The best approach is extend the SimpleChannelUpstreamHandler's
channelConnected(..) {}
messageReceived(..) {}
channelDisconnected(..) {}
methods and react to those events. you can keep the state in that handler too.