closeSocket:fail WebSocket is not connected
//替换productKey为你自己的产品的
client = mqtt.connect('wxs://a17uGeiNcLU.iot-as-mqtt.cn-shanghai.aliyuncs.com', options)
client.on('connect', function () {
that.setData({
connect_text: "连接服务器成功",
iot_connect: true
})
//订阅主题,替换productKey和deviceName(这里的主题可能会不一样,具体请查看后台设备Topic列表或使用自定义主题)
client.subscribe('/a17uGeiNcLU/console1/user/message', function (err) {
if (!err) {
console.log('订阅成功!');
}
})
client.subscribe('/a17uGeiNcLU/console1/user/back', function (err) {
if (!err) {
console.log('回收成功!');
}
})
})
[图片]