Skip to content

Qos功能心跳问题 #3165

Closed
Closed

Description

@lkj41110

背景

在看Qos模块的时候发现,pipeline中添加了IdleStateHandler来检测心跳,但是后面的Handler中,并没有发现处理心跳事件的地方,这个是不是漏掉了心跳的处理,超过5分钟断开连接呢?

 @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        if (in.readableBytes() < 1) {
            return;
        }

        // read one byte to guess protocol
        final int magic = in.getByte(in.readerIndex());

        ChannelPipeline p = ctx.pipeline();
        p.addLast(new LocalHostPermitHandler(acceptForeignIp));
        if (isHttp(magic)) {
            // no welcome output for http protocol
            if (welcomeFuture != null && welcomeFuture.isCancellable()) {
                welcomeFuture.cancel(false);
            }
            p.addLast(new HttpServerCodec());
            p.addLast(new HttpObjectAggregator(1048576));
            p.addLast(new HttpProcessHandler());
            p.remove(this);
        } else {
            p.addLast(new LineBasedFrameDecoder(2048));
            p.addLast(new StringDecoder(CharsetUtil.UTF_8));
            p.addLast(new StringEncoder(CharsetUtil.UTF_8));
            p.addLast(new IdleStateHandler(0, 0, 5 * 60));  //心跳检测
            p.addLast(new TelnetProcessHandler());
            p.remove(this);
        }
    }```

Activity

  1. gudegg commented on Jan 7, 2019

    @gudegg
    Contributor

    netty已经帮你实现了;可以看下IdleStateHandler的实现,里面有定时器

  2. lkj41110 commented on Jan 8, 2019

    @lkj41110
    ContributorAuthor

    netty已经帮你实现了;可以看下IdleStateHandler的实现,里面有定时器

    IdleStateHandler里面也只是触发userEventTriggered事件,但是在qos里好像没有找到相关的userEventTriggered处理

  3. CrazyHZM commented on Jan 8, 2019

    @CrazyHZM
    Member

    你的意思是需要对检测到断开后加上处理对吗

  4. carryxyh commented on Jan 8, 2019

    @carryxyh
    Member

    @lkj41110
    这个地方好像确实是没加。提交个PR加上吧,idle的情况下直接close掉channel即可。

  5. added
    help wanted
    on Jan 8, 2019
  6. added a commit that references this issue on Jan 8, 2019
    fad88db
  7. added a commit that references this issue on Jan 18, 2019
    ad7497e
  8. added a commit that references this issue on Mar 26, 2019
    897b80d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions