mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update异常后删除连接
This commit is contained in:
@@ -180,6 +180,8 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
|
||||
if (flag) {
|
||||
log.error("发生异常,关闭链接,channelId:{}, pileSn:{}", channelId.asShortText(), pileSn);
|
||||
ctx.channel().close();
|
||||
|
||||
close(channelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,6 +203,16 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
log.error("【{}】发生了错误, pileSn:【{}】此连接被关闭, 此时连通数量: {}", channelId, pileSn, CHANNEL_MAP.size());
|
||||
ctx.channel().close();
|
||||
|
||||
close(channelId);
|
||||
}
|
||||
}
|
||||
|
||||
private void close(ChannelId channelId) {
|
||||
// 删除桩编号和channel的关系
|
||||
PileChannelEntity.removeByChannelId(channelId.asLongText());
|
||||
|
||||
// 删除连接
|
||||
CHANNEL_MAP.remove(channelId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user