Skip to content

Commit 6514710

Browse files
authored
Merge pull request #127 from rdkelley/events
Add unique ID to mqtt client id, remove exhut dep check on Sensors map
2 parents 7cd2a4e + ca28ea8 commit 6514710

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

web/api/datasources/mqtt.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { DataSource } = require('apollo-datasource');
2+
const generator = require('generate-password');
23

34
const mqtt = require('mqtt');
45

@@ -30,10 +31,19 @@ if (
3031
mqttPort = mqtt.port;
3132
}
3233

34+
// Generates a ID to add to end of Mqtt clientId
35+
const clientUnique = generator.generate({
36+
length: 8,
37+
numbers: true,
38+
symbols: false,
39+
});
40+
41+
console.log('MQTT Unique ID:', clientUnique);
42+
3343
const client = mqtt.connect(
3444
`mqtt://${brokerId}.messaging.internetofthings.ibmcloud.com`,
3545
{
36-
clientId: mqttClientId,
46+
clientId: `${mqttClientId}:${clientUnique}`,
3747
username: mqttUsername,
3848
password: mqttPassword,
3949
port: mqttPort,

web/client/src/components/SensorsMap/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ const SensorsMap = ({ sensors, setDisplayedSensor, setShouldShowSideMenu }) => {
162162
})
163163
})
164164
}
165+
// eslint-disable-next-line react-hooks/exhaustive-deps
165166
}, [sensors])
166167

167168
const zoomIn = () => {

0 commit comments

Comments
 (0)