feat: 修复跨服传送时的错误

This commit is contained in:
2023-06-10 23:35:07 +08:00
parent 70fda95767
commit 1fec3fb429
4 changed files with 20 additions and 3 deletions

View File

@@ -58,7 +58,7 @@ public class BallServerChannelInitializer extends ChannelInitializer<SocketChann
}
channel.pipeline()
.addLast(new IdleStateHandler(10, 0, 0, TimeUnit.SECONDS))
.addLast(new IdleStateHandler(60, 0, 0, TimeUnit.SECONDS))
.addLast(new BallServerKeepAliveHandler())
.addLast(new LengthFieldPrepender(8))
.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 8, 0, 8))

View File

@@ -13,10 +13,10 @@ public class BallServerKeepAliveHandler extends SimpleUserEventChannelHandler<Id
@Override
protected void eventReceived(ChannelHandlerContext context, IdleStateEvent event) {
context.close();
synchronized (BallServerChannelInitializer.CHANNELS) {
BallServerChannelInitializer.CHANNELS.remove(context.channel());
}
context.close();
LOGGER.warn("由于无法验证连接存活,与服务器 {} 的连接已断开.", context.channel().remoteAddress());
}
}