mqtt初始化链接调试

This commit is contained in:
Timer
2026-02-24 00:13:36 +08:00
parent 4e39491e5c
commit e35f300cff
3 changed files with 24 additions and 13 deletions

View File

@ -12,6 +12,7 @@ import com.sipai.entity.mqtt.MqttConfigTopic;
import com.sipai.service.mqtt.MqttConfigService; import com.sipai.service.mqtt.MqttConfigService;
import com.sipai.service.mqtt.MqttConfigTopicService; import com.sipai.service.mqtt.MqttConfigTopicService;
import com.sipai.tools.CommUtil; import com.sipai.tools.CommUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
@ -37,6 +38,7 @@ import java.util.List;
* @Date: 2021/03/24/16:45 * @Date: 2021/03/24/16:45
* @Description: * @Description:
*/ */
@Slf4j
@Service @Service
public class MqttConfigServiceImpl implements MqttConfigService { public class MqttConfigServiceImpl implements MqttConfigService {
private final MqttProperties mqttProperties; private final MqttProperties mqttProperties;
@ -152,6 +154,7 @@ public class MqttConfigServiceImpl implements MqttConfigService {
mqttClient1.setCallback(new PushCallback(mqttClient1, connOpts, topic, qos)); mqttClient1.setCallback(new PushCallback(mqttClient1, connOpts, topic, qos));
//订阅 //订阅
mqttClient1.subscribe(topic, qos); mqttClient1.subscribe(topic, qos);
System.out.println("已连接成功");
} else { } else {
System.out.println("重新连接"); System.out.println("重新连接");
//连接 //连接
@ -160,12 +163,15 @@ public class MqttConfigServiceImpl implements MqttConfigService {
mqttClient1.setCallback(new PushCallback(mqttClient1, connOpts, topic, qos)); mqttClient1.setCallback(new PushCallback(mqttClient1, connOpts, topic, qos));
//订阅 //订阅
mqttClient1.subscribe(topic, qos); mqttClient1.subscribe(topic, qos);
System.out.println("重新连接成功");
} }
} catch (MqttException me) { } catch (MqttException me) {
log.error("MqttException:",me);
me.printStackTrace(); me.printStackTrace();
} }
} }
System.out.println(clientId);
return clientId; return clientId;
} }

View File

@ -19,19 +19,20 @@ spring:
cluster: cluster:
nodes: 172.16.242.44:6379,172.16.242.45:6379,172.16.242.46:6379,172.16.242.47:6379,172.16.242.48:6379,172.16.242.49:6379 nodes: 172.16.242.44:6379,172.16.242.45:6379,172.16.242.46:6379,172.16.242.47:6379,172.16.242.48:6379,172.16.242.49:6379
max-redirects: 3 max-redirects: 3
password: zaqwsx password: Aa112211
timeout: 100000 timeout: 100000
data: data:
elasticsearch: elasticsearch:
cluster-name: elasticsearch-sipaiis # cluster-name: elasticsearch-sipaiis
cluster-nodes: 132.120.136.19:9200 cluster-name: my-application
cluster-nodes: 127.0.0.1:9300
datasource: datasource:
master: master:
username: sa username: sa
password: P76XB3nm36aMkN6n password: P76XB3nm36aMkN6n
jdbc-url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=SIPAIIS_WMS_HQAQ jdbc-url: jdbc:sqlserver://122.51.194.184:1433;DatabaseName=SIPAIIS_WMS_HQAQ
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
@ -39,7 +40,7 @@ spring:
js1: js1:
username: sa username: sa
password: P76XB3nm36aMkN6n password: P76XB3nm36aMkN6n
jdbc-url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=EIP_PRD_HQWS jdbc-url: jdbc:sqlserver://122.51.194.184:1433;DatabaseName=EIP_PRD_HQWS
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
@ -47,7 +48,7 @@ spring:
js2: js2:
username: sa username: sa
password: P76XB3nm36aMkN6n password: P76XB3nm36aMkN6n
jdbc-url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=EIP_PRD_HQWS jdbc-url: jdbc:sqlserver://122.51.194.184:1433;DatabaseName=EIP_PRD_HQWS
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
@ -55,7 +56,7 @@ spring:
js3: js3:
username: sa username: sa
password: P76XB3nm36aMkN6n password: P76XB3nm36aMkN6n
jdbc-url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=EIP_PRD_HQWS jdbc-url: jdbc:sqlserver://122.51.194.184:1433;DatabaseName=EIP_PRD_HQWS
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
@ -145,10 +146,14 @@ app:
max-points: 200 #实时数据接口一次最多点位数 max-points: 200 #实时数据接口一次最多点位数
mqtt: mqtt:
broker-address: "tcp://192.168.10.17:1883" # broker-address: "tcp://192.168.10.17:1883"
dashboard-01: "http://192.168.10.17:18083" # dashboard-01: "http://192.168.10.17:18083"
username: "admin" # username: "admin"
password: "sipai@64368180" # password: "sipai@64368180"
broker-address: "tcp://121.5.164.6:1883"
dashboard-01: "http://121.5.164.6:18083"
username: "dmbroker"
password: "qwer1234"
# udp服务 # udp服务
udp: udp:

View File

@ -1,4 +1,4 @@
spring: spring:
profiles: profiles:
# active: dev active: dev
active: pro # active: pro