|
|
@ -277,19 +277,29 @@ public class NonAutomaticWarningController extends BaseController { |
|
|
|
}); |
|
|
|
|
|
|
|
// 建立连接
|
|
|
|
logger.info("连接到 broker: " + host); |
|
|
|
client.connect(options); |
|
|
|
try { |
|
|
|
logger.info("连接到 broker: " + host); |
|
|
|
client.connect(options); |
|
|
|
|
|
|
|
logger.info("连接成功."); |
|
|
|
//订阅消息
|
|
|
|
//client.subscribe(topicName.getString("6274883585"), 1);
|
|
|
|
//logger.info("开始监听" + topicName.getString("6274883585"));
|
|
|
|
client.subscribe(topicName.getString("6274879489"), UniversalEnum.ONE.getNumber()); |
|
|
|
logger.info("开始监听" + topicName.getString("6274879489")); |
|
|
|
//client.subscribe(topicName.getString("7768236033"), 1);
|
|
|
|
//logger.info("开始监听" + topicName.getString("7768236033"));
|
|
|
|
//client.subscribe(topicName.getString("7835340801"), 1);
|
|
|
|
//logger.info("开始监听" + topicName.getString("7835340801"));
|
|
|
|
logger.info("连接成功."); |
|
|
|
//订阅消息
|
|
|
|
//client.subscribe(topicName.getString("6274883585"), 1);
|
|
|
|
//logger.info("开始监听" + topicName.getString("6274883585"));
|
|
|
|
client.subscribe(topicName.getString("6274879489"), UniversalEnum.ONE.getNumber()); |
|
|
|
logger.info("开始监听" + topicName.getString("6274879489")); |
|
|
|
//client.subscribe(topicName.getString("7768236033"), 1);
|
|
|
|
//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(); |
|
|
|
} |
|
|
|