修改mqtt配置port:80,connectUrl增加固定地址endpoint: "/mqtt",

This commit is contained in:
qiudan 2024-04-07 18:12:06 +08:00
parent 81f245975a
commit 4a0e44f51d
1 changed files with 3 additions and 3 deletions

View File

@ -21,7 +21,7 @@ class mqttHandle {
connectTimeout: 5000, // 超时时间 connectTimeout: 5000, // 超时时间
reconnectPeriod: 3000, // 重连时间间隔 reconnectPeriod: 3000, // 重连时间间隔
host: ip, host: ip,
port: '10087', port: '80',
// 认证信息 // 认证信息
// clientId: Number(new Date()).toString(), // clientId: Number(new Date()).toString(),
clientId: newName, clientId: newName,
@ -52,9 +52,9 @@ class mqttHandle {
} = this.connect; } = this.connect;
console.log("this.connect.host", this.connect.host) console.log("this.connect.host", this.connect.host)
// const connectUrl = 'ws://172.16.1.168:10087/'; // const connectUrl = 'ws://172.16.1.168:10087/';
let connectUrl = `ws://${this.connect.host}:${this.connect.port}`; let connectUrl = `ws://${this.connect.host}${endpoint}`;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
connectUrl = 'ws://172.16.1.168:10087/'; connectUrl = `ws://172.16.1.168${endpoint}`;
} }
// if (!client.connected) { // if (!client.connected) {
// client.on('connect', function () { // client.on('connect', function () {