Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
iamlinhui committed May 27, 2022
1 parent 35b8d63 commit d72b6d2
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
String clientKey = ctx.channel().attr(Constants.Server.CLIENT_KEY).getAndSet(null);
logger.info("服务端-客户端连接中断,{}", clientKey == null ? "未知连接/代理连接" : clientKey);
// 代理连接/未知连接
if (Objects.isNull(clientKey)) {
Channel localChannel = ctx.channel().attr(Constants.LOCAL).get();
if (Objects.nonNull(localChannel) && localChannel.isActive()) {
logger.info("服务端-客户端代理连接中断");
localChannel.writeAndFlush(EmptyArrays.EMPTY_BYTES).addListener(ChannelFutureListener.CLOSE);
}
logger.info("服务端-客户端未知连接中断");
return;
}
logger.info("服务端-客户端连接中断,{}", clientKey);
Optional.ofNullable(ctx.channel().attr(Constants.CHANNELS).getAndSet(null)).ifPresent(this::clear);
Optional.ofNullable(ctx.channel().attr(Constants.Server.DOMAIN).getAndSet(null)).ifPresent(ServerChannelCache::remove);
Optional.ofNullable(ctx.channel().attr(Constants.Server.REMOTE_BOSS_GROUP).getAndSet(null)).ifPresent(AbstractEventExecutorGroup::shutdownGracefully);
Expand Down

0 comments on commit d72b6d2

Please sign in to comment.