Skip to content

Commit

Permalink
use random clientId (+ VRM token ID) for MQTT identification
Browse files Browse the repository at this point in the history
  • Loading branch information
mman committed Jun 28, 2024
1 parent 65de437 commit 1490041
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/server/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,17 +398,22 @@ Loader.prototype.connect = function (
isVrm = false
) {
return new Promise((resolve, reject) => {
const clientId = Math.random().toString(16).slice(3)
let options
this.logger.info('connecting to %s:%d', address, port)
if (isVrm) {
options = {
rejectUnauthorized: false,
username: `${this.app.config.secrets.vrmUsername}`,
password: `Token ${this.app.config.secrets.vrmToken}`,
reconnectPeriod: 0
// use random clientId + vrmTokenId to identify this loader instance
clientId: `venus_influx_loader_${clientId}_${this.app.config.secrets.vrmTokenId}`,
}
} else {
options = {}
options = {
// use random clientId to identify this loader instance
clientId: `venus_influx_loader_${clientId}`,
}
}
const client = mqtt.connect(`${isVrm ? 'mqtts' : 'mqtt'}:${address}:${port}`, options)
this.setupClient(client, address, info, isVrm)
Expand Down

0 comments on commit 1490041

Please sign in to comment.