Skip to content

Commit

Permalink
✨ 优化 mica-mqtt-client 启动改为默认同步连接
Browse files Browse the repository at this point in the history
  • Loading branch information
li-xunhuan committed Jan 11, 2024
1 parent 68f4340 commit 750de97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<properties>
<!-- mica-mqtt version -->
<revision>2.2.7</revision>
<revision>2.2.8-SNAPSHOT</revision>
<!-- java version -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ public void config(Consumer<MqttClientCreator> consumer) {
@Override
public boolean start() {
if (this.mqttClient == null) {
this.mqttClient = clientCreator.connect();
// 连接超时时间,如果没设置,改成 3s,减少因连不上卡顿时间
Integer timeout = clientCreator.getTimeout();
if (timeout == null) {
clientCreator.timeout(3);
}
// 使用同步连接
this.mqttClient = clientCreator.connectSync();
} else {
this.mqttClient.reconnect();
}
Expand Down

0 comments on commit 750de97

Please sign in to comment.