Skip to content

Commit

Permalink
Merge pull request #127 from rdkelley/events
Browse files Browse the repository at this point in the history
Add unique ID to mqtt client id, remove exhut dep check on Sensors map
  • Loading branch information
rdkelley authored May 24, 2021
2 parents 7cd2a4e + ca28ea8 commit 6514710
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 6514710

Please sign in to comment.