在netty管道初始化之前消息是否可能出现?

时间:2017-10-08 12:52:55

标签: netty

我有下一个管道:

        @Override
        protected void initChannel(SocketChannel ch) throws Exception {
            final ChannelPipeline pipeline = ch.pipeline();

            if (hardTimeoutSecs > 0) {
                pipeline.addLast("H_ReadTimeout", new ReadTimeoutHandler(30));
            }
            pipeline.addLast("H_ChannelState", hardwareChannelStateHandler)
            .addLast("H_MessageDecoder", new MessageDecoder())
            .addLast("H_MessageEncoder", new MessageEncoder())
            .addLast("H_Login", hardwareLoginHandler)
            .addLast("H_NotLogged", new HardwareNotLoggedHandler())
            .addLast("H_AlreadyLogged", alreadyLoggedHandler);
        }

工作正常。但是,有时在日志中我会看到下一个警告:

12:25:01.675 DEBUG- Discarded inbound message PooledUnsafeDirectByteBuf(ridx: 0, wi
dx: 186, cap: 186) that reached at the tail of the pipeline. Please check your pipe
line configuration.

我修补了Netty以获取更多信息并添加到TailContext:

logger.debug("Reached end of the pipeline for handlers : {}.", Arrays.toString(ctx.pipeline().names().toArray()));

在我得到这个补丁之后:

12:25:01.675 DEBUG- Reached end of the pipeline for handlers : [H_ReadTimeout, H_ChannelState, DefaultChannelPipeline$TailContext#0].
12:25:01.675 DEBUG- Discarded inbound message PooledUnsafeDirectByteBuf(ridx: 0, widx: 186, cap: 186) that reached at the tail of the pipeline. Please check your pipeline configuration.

您可以看到该消息在我的管道H_ReadTimeoutH_ChannelState中仅显示了2个处理程序。

我不明白 - 这怎么可能?有人有任何线索吗?

我唯一的建议是在管道初始化之前发出消息。我是对的吗?

P上。 S.我不会删除代码中的处理程序。

Netty:4.1.16-决赛。

0 个答案:

没有答案