Skip to content

Commit

Permalink
Add unique ID to mqtt client id, remove exhut dep check
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Kelley <rdkelley@users.noreply.github.com>
  • Loading branch information
rdkelley committed May 24, 2021
1 parent 7cd2a4e commit ca28ea8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion web/api/datasources/mqtt.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { DataSource } = require('apollo-datasource');
const generator = require('generate-password');

const mqtt = require('mqtt');

Expand Down Expand Up @@ -30,10 +31,19 @@ if (
mqttPort = mqtt.port;
}

// Generates a ID to add to end of Mqtt clientId
const clientUnique = generator.generate({
length: 8,
numbers: true,
symbols: false,
});

console.log('MQTT Unique ID:', clientUnique);

const client = mqtt.connect(
`mqtt://${brokerId}.messaging.internetofthings.ibmcloud.com`,
{
clientId: mqttClientId,
clientId: `${mqttClientId}:${clientUnique}`,
username: mqttUsername,
password: mqttPassword,
port: mqttPort,
Expand Down
1 change: 1 addition & 0 deletions web/client/src/components/SensorsMap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const SensorsMap = ({ sensors, setDisplayedSensor, setShouldShowSideMenu }) => {
})
})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sensors])

const zoomIn = () => {
Expand Down

0 comments on commit ca28ea8

Please sign in to comment.