同一个(vue)画面地址,pc打开后能正常接收到mqtt推送数据,移动端无法接收mqtt推送数据
测试dataForm.client.on 移动端没有正常触发
const { host, port, endpoint, …options } = dataForm.connection
const connectUrl = ws://${host}:${port}${endpoint}
try {
dataForm.client = mqtt.connect(connectUrl, options)
} catch (error) {
console.log(‘mqtt.connect error’, error)
}
dataForm.client.on(‘connect’, () => {
dataForm.user.content = 101
console.log(‘Connection succeeded!’)
console.log(dataForm.connection.clientId)
const { topic, qos } = dataForm.subscription
dataForm.client.subscribe(topic, qos, (error, res) => {
if (error) {
console.log(‘Subscribe to topics error’, error)
return
}
dataForm.subscribeSuccess = true
console.log(‘Subscribe to topics res’, res)
})
})
dataForm.client.on(‘error’, error => {
dataForm.user.content = 0
console.log(‘Connection failed’, error)
})
dataForm.client.on(‘message’, (topic, message) => {
dataForm.user.content = message.toString();
})