|
|
|
@ -71,12 +71,17 @@ const createConnection = (callback?) => {
|
|
|
|
|
};
|
|
|
|
|
addOrUpdateRedisUser(querys);
|
|
|
|
|
}
|
|
|
|
|
const { protocol, host, port, endpoint, ...options } = connection;
|
|
|
|
|
const connectUrl = `${protocol}://${host}:${port}${endpoint}`;
|
|
|
|
|
client = mqtt.connect(connectUrl, options);
|
|
|
|
|
client.on('connect', () => {
|
|
|
|
|
if(callback){
|
|
|
|
|
callback()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
// const clientId = 'mqttx_' + Math.random().toString(16).substring(2, 8);
|
|
|
|
|
// connection.clientId = clientId;
|
|
|
|
|
const { protocol, host, port, endpoint, ...options } = connection;
|
|
|
|
|
const connectUrl = `${protocol}://${host}:${port}${endpoint}`;
|
|
|
|
|
client = mqtt.connect(connectUrl, options);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log('mqtt.connect error', error);
|
|
|
|
|
}
|
|
|
|
|