コードスニペット。
サーバーへの接続に hello を書き込もうとしています。接続が確立されると channelActive が呼び出され、コンテキストを使用して応答を書き込むと仮定します。しかし、クライアントでは何も受信されません。
public class EchoServerHandler extends ChannelInboundHandlerAdapter {
....
//edit checking status of future
public void channelActive(ChannelHandlerContext ctx) throws Exception {
super.channelActive(ctx);
// ChannelFuture f = ctx.write("hello"); //EDIT2 : cant use String use ByteBuf
ByteBuf msg = Unpooled.copiedBuffer("hello", CharsetUtil.UTF_8);
ctx.write(msg);
if (f.isSuccess()) {
System.out.println("success");
}
else {
System.out.println("failed");
f.cause().printStackTrace(); // EDIT2: Helpful in determining cause of failure
}
if (f.isDone()) {
System.out.println("Done");
}else
{
System.out.println("Not Done");
}
System.out.println("channelActive");
} .....
}