Commit 2031ac45 authored by Administrator's avatar Administrator

log

parent a0512be4
......@@ -70,7 +70,7 @@ public class NatServerChannelHandler extends SimpleChannelInboundHandler<NatMess
Channel userMappingChannel = client.queryUserMappingChannel(seq);
if (userMappingChannel == null) {
log.warn("can not find userMapping channel for request :{} client:{}", seq, client);
log.warn("can not find userMapping channel for request :{} client:{} when connection ready", seq, client);
NatMessage natMessage = new NatMessage();
natMessage.setType(NatMessage.TYPE_DISCONNECT);
natMessage.setSerialNumber(seq);
......@@ -112,7 +112,7 @@ public class NatServerChannelHandler extends SimpleChannelInboundHandler<NatMess
Channel userMappingChannel = client.queryUserMappingChannel(seq);
if (userMappingChannel == null) {
log.warn("can not find userMapping channel for request :{} client:{}", seq, client);
log.warn("can not find userMapping channel for request :{} client:{} ,send a close message to client endpoint", seq, client);
NatMessage natMessage = new NatMessage();
natMessage.setType(NatMessage.TYPE_DISCONNECT);
natMessage.setSerialNumber(seq);
......@@ -147,7 +147,7 @@ public class NatServerChannelHandler extends SimpleChannelInboundHandler<NatMess
Channel userMappingChannel = client.queryUserMappingChannel(seq);
if (userMappingChannel == null) {
log.warn("can not find userMapping channel for request :{} client:{}", seq, client);
log.warn("can not find userMapping channel for request :{} client:{} when recieved disconnect message", seq, client);
return;
}
userMappingChannel.close();
......
......@@ -33,6 +33,9 @@ public class ClientManager {
natClientImage.getNatChannel().close();
natClientImage.closeAllUserChannel();
mappingPort = natClientImage.getMappingPort();
//需要关闭所有的连接,但是计数器不能清零。计数器清零可能导致紊乱
natClientImage.updateChannel(channel);
} else {
mappingPort = AvailablePortResManager.allocate();
if (mappingPort == null) {
......@@ -50,12 +53,11 @@ public class ClientManager {
log.warn("bind mapping port:{} failed", mappingPort, channelFuture.cause());
return false;
}
natClientImage = new NatClientImage(client, mappingPort, channel);
}
channel.attr(Constant.NAT_CHANNEL_CLIENT_KEY).set(client);
clientPortBiMap.put(client, mappingPort);
natClientImage = new NatClientImage(client, mappingPort, channel);
natClientImageMap.put(client, natClientImage);
log.info("client :{} register success,with port:{}", client, mappingPort);
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment