提交 67a993ec 编写于 作者: 浅梦2013's avatar 浅梦2013

🐛 同一个 clientId 踢出时清除老的 session。

上级 75c50d3d
......@@ -106,6 +106,7 @@ public class DefaultMqttServerProcessor implements MqttServerProcessor {
Tio.unbindBsId(otherContext);
String remark = String.format("uniqueId:[%s] clientId:[%s] now bind on new context id:[%s]", uniqueId, clientId, context.getId());
Tio.remove(otherContext, remark);
cleanSession(uniqueId);
}
// 4.5 广播上线消息,避免一个 uniqueId 多个集群服务器中连接。
sendConnected(context, uniqueId);
......@@ -174,6 +175,14 @@ public class DefaultMqttServerProcessor implements MqttServerProcessor {
messageDispatcher.send(message);
}
private void cleanSession(String clientId) {
try {
sessionManager.remove(clientId);
} catch (Throwable throwable) {
logger.error("Mqtt server clientId:{} session clean error.", clientId, throwable);
}
}
@Override
public void processPublish(ChannelContext context, MqttPublishMessage message) {
String clientId = context.getBsId();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册