createConnection方法第一次执行没有id没有连接结果问题修改

main
zhufu 2 months ago
parent f65611ae52
commit c67cf2e38b

@ -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);
}

Loading…
Cancel
Save