1、两个相同的mqtt客户端导致连接失败

This commit is contained in:
weidong 2024-08-04 10:59:03 +08:00
parent 444e7eb23c
commit 0aca5d7041

View File

@ -33,10 +33,9 @@ public class GZYMQTTForwarder2 extends Forwarder {
@Value("${mqtt.server.topic}") @Value("${mqtt.server.topic}")
private String topic; private String topic;
MQTTClient mqttClient; MQTTClient mqttClient;
@PostConstruct //@PostConstruct
void registerMe() throws MqttException { void registerMe() throws MqttException {
init(FORWARDER_NAME, "MQTT "+brokerUrl,2,FWD_DEVICE_ALIAS_NAME,10); init(FORWARDER_NAME, "MQTT "+brokerUrl,2,FWD_DEVICE_ALIAS_NAME,10);
mqttClient = new MQTTClient(brokerUrl, username, password,clientid); mqttClient = new MQTTClient(brokerUrl, username, password,clientid);
@ -46,7 +45,7 @@ public class GZYMQTTForwarder2 extends Forwarder {
/** /**
* 每半小时转发GNSS解算结果 * 每半小时转发GNSS解算结果
*/ */
@Scheduled(cron = "0 0/10 * * * ?") // 每10分钟执行一次 //@Scheduled(cron = "0 0/10 * * * ?") // 每10分钟执行一次
private void forwardGnss() { private void forwardGnss() {
logger.info("gzy mqtt forwardGnss"); logger.info("gzy mqtt forwardGnss");
forwardCurrentGnss(); forwardCurrentGnss();