提交 cb2cb035 编写于 作者: 如梦技术's avatar 如梦技术 🐛

mica-mqtt 3.1 协议会校验 clientId 长度,添加配置项 maxClientIdLength。

上级 0176925d
......@@ -4,10 +4,11 @@
### v1.0.3 - 2021-08-15
- :sparkles: mica-mqtt server 添加 websocket mqtt 子协议支持(支持 mqtt.js)。
- :sparkles: mica-mqtt server ip,默认为空,可不设置。
- :sparkles: mica-mqtt server 3.1 协议会校验 clientId 长度,添加配置项。
- :sparkles: mica-mqtt client去除 CountDownLatch 避免启动时未连接上服务端卡住。
- :sparkles: mica-mqtt client 添加最大包体长度字段,避免超过 8092 长度的包体导致解析异常。
- :sparkles: mica-mqtt client 添加连接监听 IMqttClientConnectListener。
- :sparkles: mica-mqtt 3.1 协议会校验 clientId 长度,添加配置项 maxClientIdLength。
- :sparkles: mica-mqtt 优化 mqtt 解码异常处理。
- :sparkles: mica-mqtt 日志优化,方便查询。
- :sparkles: mica-mqtt 代码优化,部分 Tio.close 改为 Tio.remove。
- :sparkles: mica-mqtt-spring-boot-example 添加 Dockerfile,支持 `spring-boot:build-image`
......
......@@ -38,7 +38,7 @@ public class MqttClientAioHandler implements ClientAioHandler {
public MqttClientAioHandler(MqttClientCreator mqttClientCreator,
IMqttClientProcessor processor) {
this.mqttDecoder = new MqttDecoder(mqttClientCreator.getMaxBytesInMessage());
this.mqttDecoder = new MqttDecoder(mqttClientCreator.getMaxBytesInMessage(), mqttClientCreator.getMaxClientIdLength());
this.mqttEncoder = MqttEncoder.INSTANCE;
this.allocator = mqttClientCreator.getBufferAllocator();
this.processor = processor;
......
......@@ -65,6 +65,10 @@ public final class MqttClientCreator {
* 消息解析最大 bytes 长度,默认:8092
*/
private int maxBytesInMessage = MqttConstant.DEFAULT_MAX_BYTES_IN_MESSAGE;
/**
* mqtt 3.1 会校验此参数
*/
private int maxClientIdLength = MqttConstant.DEFAULT_MAX_CLIENT_ID_LENGTH;
/**
* Keep Alive (s)
*/
......@@ -146,6 +150,10 @@ public final class MqttClientCreator {
return maxBytesInMessage;
}
public int getMaxClientIdLength() {
return maxClientIdLength;
}
public int getKeepAliveSecs() {
return keepAliveSecs;
}
......@@ -228,6 +236,11 @@ public final class MqttClientCreator {
return this;
}
public MqttClientCreator maxClientIdLength(int maxClientIdLength) {
this.maxClientIdLength = maxClientIdLength;
return this;
}
public MqttClientCreator keepAliveSecs(int keepAliveSecs) {
this.keepAliveSecs = keepAliveSecs;
return this;
......
......@@ -23,8 +23,8 @@
| mqtt.server.heartbeat-timeout | 1000 * 120 | 心跳超时时间(单位: 毫秒 默认: 1000 * 120) |
| mqtt.server.read-buffer-size | 8092 | 接收数据的 buffer size,默认:8092 |
| mqtt.server.max-bytes-in-message | 8092 | 消息解析最大 bytes 长度,默认:8092 |
| mqtt.server.debug | false | debug,如果开启 prometheus 指标收集建议关闭 |
| mqtt.server.max-client-id-length | 23 | mqtt 3.1 会校验此参数,其它协议版本不会 |
| mqtt.server.debug | false | debug,如果开启 prometheus 指标收集建议关闭 |
| mqtt.server.websocket-enable | true | 开启 websocket 服务,默认:true |
| mqtt.server.websocket-port | 8083 | websocket 端口,默认:8083 |
......@@ -166,6 +166,7 @@ public class ServerService {
| mqtt.client.buffer-allocator | 堆内存 | ByteBuffer Allocator,支持堆内存和堆外内存,默认为:堆内存 |
| mqtt.client.read-buffer-size | 8092 | t-io 每次消息读取长度,跟 maxBytesInMessage 相关 |
| mqtt.client.max-bytes-in-message | 8092 | 消息解析最大 bytes 长度,默认:8092 |
| mqtt.client.max-client-id-length | 23 | mqtt 3.1 会校验此参数,其它协议版本不会 |
| mqtt.client.reconnect | true | 自动重连 |
| mqtt.client.re-interval | 5000 | 重连重试时间,单位毫秒 |
| mqtt.client.timeout | 5 | 超时时间,单位秒,t-io 配置,可为 null |
......
......@@ -56,6 +56,7 @@ public class MqttClientConfiguration {
.clientId(properties.getClientId())
.readBufferSize(properties.getReadBufferSize())
.maxBytesInMessage(properties.getMaxBytesInMessage())
.maxClientIdLength(properties.getMaxClientIdLength())
.keepAliveSecs(properties.getKeepAliveSecs())
.reconnect(properties.isReconnect())
.version(properties.getVersion())
......
......@@ -78,6 +78,10 @@ public class MqttClientProperties {
* 消息解析最大 bytes 长度,默认:8092
*/
private int maxBytesInMessage = MqttConstant.DEFAULT_MAX_BYTES_IN_MESSAGE;
/**
* mqtt 3.1 会校验此参数
*/
private int maxClientIdLength = MqttConstant.DEFAULT_MAX_CLIENT_ID_LENGTH;
/**
* Keep Alive (s)
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册