connectMqtt: function(id) {
var clinet_id = parseInt(Math.random() * 100 + 888888888, 10);
console.log('wx_' + clinet_id);
const options = {
connectTimeout: 4000,
clientId: 'wx_' + clinet_id,
}
client = mqtt.connect('wxs://www.bmums.cn:8084/mqtt', options)
client.on('reconnect', (error) => {
console.log('正在重连:', error)
})
client.on('error', (error) => {
console.log('连接失败:', error)
})
let that = this;
var arr='$USR/DevJsonTx/';
var sub=arr.concat(id)
client.on('connect', (e) => {
console.log('成功连接服务器')
client.subscribe(sub, {
qos: 0
}, function(err) {
if (!err) {
console.log("订阅成功")
}
})
})
client.on('message', function (topic, message) {{
})
请问楼主解决了吗