|
|
@ -277,6 +277,7 @@ public class NonAutomaticWarningController extends BaseController { |
|
|
|
}); |
|
|
|
|
|
|
|
// 建立连接
|
|
|
|
try { |
|
|
|
logger.info("连接到 broker: " + host); |
|
|
|
client.connect(options); |
|
|
|
|
|
|
@ -290,6 +291,15 @@ public class NonAutomaticWarningController extends BaseController { |
|
|
|
//logger.info("开始监听" + topicName.getString("7768236033"));
|
|
|
|
//client.subscribe(topicName.getString("7835340801"), 1);
|
|
|
|
//logger.info("开始监听" + topicName.getString("7835340801"));
|
|
|
|
} catch (MqttException e) { |
|
|
|
if (e.getReasonCode() == MqttException.REASON_CODE_CLIENT_TIMEOUT) { |
|
|
|
logger.warn("连接超时."); |
|
|
|
// 尝试重连
|
|
|
|
getAjaxResult(parameter); |
|
|
|
} else { |
|
|
|
throw e; // 抛出其他类型的异常
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|