netty Failed to submit an exceptionCaught() event异常

本文探讨了Netty服务端应用在关闭过程中遇到的异常情况,并深入分析了其原因,主要由于未主动断开客户端连接及客户端心跳线程的影响。文章提供了具体的解决方案,包括主动断开所有客户端连接的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近测试netty开发的服务端应用在关闭时,出现下列异常:

-》###WARN#########nioEventLoopGroup-3-2###io.netty.util.internal.logging.Slf4JLogger.warn(Slf4JLogger.java:151)###Failed to submit an exceptionCaught() event.
java.util.concurrent.RejectedExecutionException: event executor terminated
at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:805)
at io.netty.util.concurrent.SingleThreadEventExecutor.offerTask(SingleThreadEventExecutor.java:345)
at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:338)
at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:748)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:272)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:261)
at io.netty.channel.ChannelHandlerAdapter.exceptionCaught(ChannelHandlerAdapter.java:79)

 经查,发现是因为关闭服务端的时候,主要是因为没有主动断开客户端的连接,而客户端又有心跳线程所致。而此时work-group线程组已经关闭了。先调整为主动断开所有的客户端连接。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值