首页 > 解决方案 > IdleStateHandler AllIdleTimeoutTask 在指定的超时之前被触发

问题描述

我们有一个处理程序来侦听扩展 ChannelInboundHandlerAdapter 的通道非活动事件。

该通道由 SimpleChannelPool 提供。通道管道的配置如片段中所述,其中处理程序是 ChannelInboundHandlerAdapter 的扩展。

问题是,在某些时候,方法 ChannelInboundHandlerAdapter#channelInactive 在指定的 10000 毫秒超时之前被调用。就像在500毫秒左右。我猜 AllIdleTimeoutTask 在预期的超时之前就开始了。一些人表示,在他们将服务切换到新的 AMI 实例后,问题就开始发生了。还没有机会在本地复制这个。

对此有什么想法吗?

ch.pipeline().addLast("idle", new IdleStateHandler(0, 0, 10000, TimeUnit.MILLISECONDS)).addLast("handler", handler);

这是超时时记录的堆栈。

在 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) 在 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) 在 io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224 ) 在 io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) 在 io.netty.handler.timeout.IdleStateHandler.channelInactive(IdleStateHandler.java:277) 在 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext. java:245) 在 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) 在 io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) 在 io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) 在 io.netty.handler.codec.MessageAggregator.channelInactive(MessageAggregator.java:417) 在 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext .java:245) 在 io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) 在 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) 在 io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext。 fireChannelInactive(CombinedChannelDuplexHandler.java:420) at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:377) at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:342) 在 io.netty.handler.codec.http.HttpClientCodec$Decoder.channelInactive(HttpClientCodec.java:281) 在 io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:223) 在 io.netty.channel.AbstractChannelHandlerContext .invokeChannelInactive(AbstractChannelHandlerContext.java:245) 在 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) 在 io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) 在 io.netty.handler。 logging.LoggingHandler.channelInactive(LoggingHandler.java:167) 在 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) 在 io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) 在 io.netty .channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245) at io.netty .channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231) 在 io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224) 在 io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1354) 在io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java: io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)231) 在 io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:763) 在 io.netty.util.concurrent.AbstractEventExecutor 的 io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:917)。 safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTask​​s(SingleThreadEventExecutor.java:403) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) at io.netty .util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) 在 io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTask​​s(SingleThreadEventExecutor.java:403) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) at io .netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTask​​s(SingleThreadEventExecutor.java:403) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463) at io .netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)运行(DefaultThreadFactory.java:138)运行(DefaultThreadFactory.java:138)

标签: javanetty

解决方案


推荐阅读