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:
@@ -3,6 +3,7 @@ package com.jsowell.netty.server.yunkuaichong;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.enums.ykc.PileChannelEntity;
|
||||
import com.jsowell.common.util.BytesUtil;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.common.util.YKCUtils;
|
||||
import com.jsowell.netty.service.yunkuaichong.YKCBusinessService;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -178,10 +179,8 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
|
||||
log.error("Client-IP:【{}】, channelId:【{}】, pileSn:【{}】, ALL_IDLE 总超时", socketString, channelId, pileSn);
|
||||
}
|
||||
if (flag) {
|
||||
log.error("发生异常,关闭链接,channelId:{}, pileSn:{}", channelId.asShortText(), pileSn);
|
||||
ctx.channel().close();
|
||||
|
||||
close(channelId);
|
||||
close(channelId, pileSn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,15 +202,17 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
|
||||
}
|
||||
log.error("【{}】发生了错误, pileSn:【{}】此连接被关闭, 此时连通数量: {}", channelId, pileSn, CHANNEL_MAP.size());
|
||||
ctx.channel().close();
|
||||
|
||||
close(channelId);
|
||||
}
|
||||
close(channelId, pileSn);
|
||||
}
|
||||
|
||||
private void close(ChannelId channelId) {
|
||||
// 删除桩编号和channel的关系
|
||||
PileChannelEntity.removeByChannelId(channelId.asLongText());
|
||||
private void close(ChannelId channelId, String pileSn) {
|
||||
log.error("close方法-发生异常,关闭链接,channelId:{}, pileSn:{}", channelId.asShortText(), pileSn);
|
||||
|
||||
// 删除桩编号和channel的关系
|
||||
if (StringUtils.isNotBlank(pileSn)) {
|
||||
PileChannelEntity.removeByPileSn(pileSn);
|
||||
}
|
||||
// 删除连接
|
||||
CHANNEL_MAP.remove(channelId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user