diff --git a/web/api/datasources/mqtt.js b/web/api/datasources/mqtt.js index 6a960c0..5078136 100644 --- a/web/api/datasources/mqtt.js +++ b/web/api/datasources/mqtt.js @@ -1,4 +1,5 @@ const { DataSource } = require('apollo-datasource'); +const generator = require('generate-password'); const mqtt = require('mqtt'); @@ -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, diff --git a/web/client/src/components/SensorsMap/index.js b/web/client/src/components/SensorsMap/index.js index 9bf4898..b519b1e 100644 --- a/web/client/src/components/SensorsMap/index.js +++ b/web/client/src/components/SensorsMap/index.js @@ -162,6 +162,7 @@ const SensorsMap = ({ sensors, setDisplayedSensor, setShouldShowSideMenu }) => { }) }) } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [sensors]) const zoomIn = () => {