在Netty处理器里面channelRead方法service查询数据库报错
io.netty.channel.DefaultChannelPipeline : An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
解决方法:
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
super.exceptionCaught(ctx, cause);
Channel channel = ctx.channel();
//……
if(channel.isActive())ctx.close();
}
不知道你这个问题是否已经解决, 如果还没有解决的话:ChannelHandler
会处理I/O
事件或拦截I/O
操作,并将其转发到ChannelPipeline
中的下一个ChannelHandler
。ChannelHandler
本身并没有提供很多方法,通常需要实现其子类型之一:
ChannelInboundHandler
:处理入站I/O
事件的抽象。ChannelOutboundHandler
:处理出站I/O
操作的抽象。为了方便,Netty
提供了以下适配器类:
ChannelInboundHandlerAdapter
:处理入站I/O
事件的一种简单实现。ChannelOutboundHandlerAdapter
:处理出站I/O
操作的一种简单实现。