Skip to content

Commit

Permalink
✨ 优化支持的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunMengLu committed Jul 30, 2024
1 parent 8393cc1 commit 3c98f39
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ mqtt:
ip: 127.0.0.1 # 连接的服务端 ip ,默认:127.0.0.1
port: 18889 # 端口:默认:1883
name: Mica-Mqtt-Client # 名称,默认:Mica-Mqtt-Client
# clientId: 000001 # 客户端Id(非常重要,一般为设备 sn,不可重复)
# user-name: mica # 认证的用户名
# password: mica # 认证的密码
# timeout: 5 # 超时时间,单位:秒,默认:5秒
# reconnect: true # 是否重连,默认:true
# re-interval: 5000 # 重连时间,默认 5000 毫秒
# version: mqtt_3_1_1 # mqtt 协议版本,可选 MQTT_3_1、mqtt_3_1_1、mqtt_5,默认:mqtt_3_1_1
# read-buffer-size: 8KB # 接收数据的 buffer size,默认:8k
# max-bytes-in-message: 10MB # 消息解析最大 bytes 长度,默认:10M
# buffer-allocator: heap # 堆内存和堆外内存,默认:堆内存
# keep-alive-secs: 60 # keep-alive 时间,单位:秒
# clean-session: true # mqtt clean session,默认:true
# ssl:
# enabled: false # 是否开启 ssl 认证,2.1.0 开始支持双向认证
# keystore-path: # 可选参数:ssl 双向认证 keystore 目录,支持 classpath:/ 路径。
# keystore-pass: # 可选参数:ssl 双向认证 keystore 密码
# truststore-path: # 可选参数:ssl 双向认证 truststore 目录,支持 classpath:/ 路径。
# truststore-pass: # 可选参数:ssl 双向认证 truststore 密码
clientId: 000001 # 客户端Id(非常重要,一般为设备 sn,不可重复)
user-name: mica # 认证的用户名
password: mica # 认证的密码
timeout: 5 # 超时时间,单位:秒,默认:5秒
reconnect: true # 是否重连,默认:true
re-interval: 5000 # 重连时间,默认 5000 毫秒
version: mqtt_3_1_1 # mqtt 协议版本,可选 MQTT_3_1、mqtt_3_1_1、mqtt_5,默认:mqtt_3_1_1
read-buffer-size: 8KB # 接收数据的 buffer size,默认:8k
max-bytes-in-message: 10MB # 消息解析最大 bytes 长度,默认:10M
buffer-allocator: heap # 堆内存和堆外内存,默认:堆内存
keep-alive-secs: 60 # keep-alive 时间,单位:秒
clean-session: true # mqtt clean session,默认:true
ssl:
enabled: false # 是否开启 ssl 认证,2.1.0 开始支持双向认证
keystore-path: # 可选参数:ssl 双向认证 keystore 目录,支持 classpath:/ 路径。
keystore-pass: # 可选参数:ssl 双向认证 keystore 密码
truststore-path: # 可选参数:ssl 双向认证 truststore 目录,支持 classpath:/ 路径。
truststore-pass: # 可选参数:ssl 双向认证 truststore 密码

topic1: /test/#
topic1: /test/#
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ mqtt:
# # ip: 0.0.0.0 # 服务端 ip 默认为空,0.0.0.0,建议不要设置
port: 18889 # 端口,默认:1883
name: Mica-Mqtt-Server # 名称,默认:Mica-Mqtt-Server
## buffer-allocator: HEAP # 堆内存和堆外内存,默认:堆内存
## heartbeat-timeout: 120000 # 心跳超时,单位毫秒,默认: 1000 * 120
## read-buffer-size: 8KB # 接收数据的 buffer size,默认:8k
## max-bytes-in-message: 10MB # 消息解析最大 bytes 长度,默认:10M
## auth:
## enable: false # 是否开启 mqtt 认证
## username: mica # mqtt 认证用户名
## password: mica # mqtt 认证密码
## debug: true # 如果开启 prometheus 指标收集建议关闭
## stat-enable: true # 开启指标收集,debug 和 prometheus 开启时需要打开,默认开启,关闭节省内存
## web-port: 8083 # http、websocket 端口,默认:8083
## websocket-enable: true # 是否开启 websocket,默认: true
## http-enable: false # 是否开启 http api,默认: false
## http-basic-auth:
## enable: false # 是否开启 http basic auth,默认: false
## username: mica # http basic auth 用户名
## password: mica # http basic auth 密码
## ssl: # mqtt tcp ssl 认证
## enabled: false # 是否开启 ssl 认证,2.1.0 开始支持双向认证
## keystore-path: # 必须参数:ssl keystore 目录,支持 classpath:/ 路径。
## keystore-pass: # 必选参数:ssl keystore 密码
## truststore-path: # 可选参数:ssl 双向认证 truststore 目录,支持 classpath:/ 路径。
## truststore-pass: # 可选参数:ssl 双向认证 truststore 密码
## client-auth: none # 是否需要客户端认证(双向认证),默认:NONE(不需要)
buffer-allocator: HEAP # 堆内存和堆外内存,默认:堆内存
heartbeat-timeout: 120000 # 心跳超时,单位毫秒,默认: 1000 * 120
read-buffer-size: 8KB # 接收数据的 buffer size,默认:8k
max-bytes-in-message: 10MB # 消息解析最大 bytes 长度,默认:10M
auth:
enable: false # 是否开启 mqtt 认证
username: mica # mqtt 认证用户名
password: mica # mqtt 认证密码
debug: true # 如果开启 prometheus 指标收集建议关闭
stat-enable: true # 开启指标收集,debug 和 prometheus 开启时需要打开,默认开启,关闭节省内存
web-port: 8083 # http、websocket 端口,默认:8083
websocket-enable: true # 是否开启 websocket,默认: true
http-enable: true # 是否开启 http api,默认: false
http-basic-auth:
enable: true # 是否开启 http basic auth,默认: false
username: mica # http basic auth 用户名
password: mica # http basic auth 密码
ssl: # mqtt tcp ssl 认证
enabled: false # 是否开启 ssl 认证,2.1.0 开始支持双向认证
keystore-path: # 必须参数:ssl keystore 目录,支持 classpath:/ 路径。
keystore-pass: # 必选参数:ssl keystore 密码
truststore-path: # 可选参数:ssl 双向认证 truststore 目录,支持 classpath:/ 路径。
truststore-pass: # 可选参数:ssl 双向认证 truststore 密码
client-auth: none # 是否需要客户端认证(双向认证),默认:NONE(不需要)
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public MqttClientCreator mqttClientCreator(MqttClientProperties properties) {
.username(properties.getUserName())
.password(properties.getPassword())
.clientId(properties.getClientId())
.readBufferSize((int) properties.getReadBufferSize().toBytes())
.maxBytesInMessage((int) properties.getMaxBytesInMessage().toBytes())
.readBufferSize((int) DataSize.parse(properties.getReadBufferSize()).toBytes())
.maxBytesInMessage((int) DataSize.parse(properties.getMaxBytesInMessage()).toBytes())
.maxClientIdLength(properties.getMaxClientIdLength())
.keepAliveSecs(properties.getKeepAliveSecs())
.reconnect(properties.isReconnect())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ public class MqttClientProperties {
/**
* 接收数据的 buffer size,默认:8k
*/
private DataSize readBufferSize = DataSize.ofBytes(MqttConstant.DEFAULT_MAX_READ_BUFFER_SIZE);
private String readBufferSize = "8k";
/**
* 消息解析最大 bytes 长度,默认:10M
*/
private DataSize maxBytesInMessage = DataSize.ofBytes(MqttConstant.DEFAULT_MAX_BYTES_IN_MESSAGE);
private String maxBytesInMessage = "10M";
/**
* mqtt 3.1 会校验此参数为 23,为了减少问题设置成了 64
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public MqttServerCreator mqttServerCreator(MqttServerProperties properties) {
.port(properties.getPort())
.heartbeatTimeout(properties.getHeartbeatTimeout())
.keepaliveBackoff(properties.getKeepaliveBackoff())
.readBufferSize((int) properties.getReadBufferSize().getBytes())
.maxBytesInMessage((int) properties.getMaxBytesInMessage().getBytes())
.readBufferSize((int) DataSize.parse(properties.getReadBufferSize()).getBytes())
.maxBytesInMessage((int) DataSize.parse(properties.getMaxBytesInMessage()).getBytes())
.bufferAllocator(properties.getBufferAllocator())
.maxClientIdLength(properties.getMaxClientIdLength())
.webPort(properties.getWebPort())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public class MqttServerProperties {
/**
* 接收数据的 buffer size,默认:8k
*/
private DataSize readBufferSize = DataSize.ofBytes(MqttConstant.DEFAULT_MAX_READ_BUFFER_SIZE);
private String readBufferSize = "8k";
/**
* 消息解析最大 bytes 长度,默认:10M
*/
private DataSize maxBytesInMessage = DataSize.ofBytes(MqttConstant.DEFAULT_MAX_BYTES_IN_MESSAGE);
private String maxBytesInMessage = "10M";
/**
* 堆内存和堆外内存
*/
Expand Down

0 comments on commit 3c98f39

Please sign in to comment.