(version: Netty 4.0.4.Final)
If the exception is raised in ChannelInboundHandler , I can handle it in the exceptionCaught() method, but if the exception is raised in ChannelOutboundHandler , I cannot. Because exceptionCaught() not a call. Why is this so?
There is only one way to handle an outgoing exception by analyzing the future result as follows:
channel.writeAndFlush(serverPacket).addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { future.cause().printStackTrace(); } } });
But it is very inconvenient.
exception-handling netty
Megaprog
source share