var mqtt = require('mqtt')
var clientId = 'my_mqtt'
var host = 'ws://接口地址'
var globalCallback=null
var options = {
keepalive: 10,
clientId: clientId,
protocolId: 'MQTT',
protocolVersion: 4,
clean: true,
reconnectPeriod: 1000,
connectTimeout: 30 * 1000,
will: {
topic: 'WillMsg',
payload: 'Connection Closed abnormally..!',
qos: 0,
retain: false
},
username: 'demo',
password: 'demo',
rejectUnauthorized: false
}
var client = mqtt.connect(host, options)
function websocketMQTT(theme){
client.on('error', function (err) {
console.log('connect is error!', err)