stop using in-container mqtt, but use external one

This commit is contained in:
Dobromir Popov
2023-05-15 13:43:49 +03:00
parent 9d8c3d74c4
commit 3749143faf
2 changed files with 13 additions and 12 deletions

View File

@@ -10,13 +10,13 @@ services:
- DATABASE_PASS=mitko2021 - DATABASE_PASS=mitko2021
- GARDEN_IP=0.0.0.0 - GARDEN_IP=0.0.0.0
# - GARDEN_IP=192.168.0.100 # - GARDEN_IP=192.168.0.100
- MQTT_HOST=node-mqtt - MQTT_HOST=192.168.0.10
- MQTT_PORT_HTTP=1883 - MQTT_PORT_HTTP=1883
- MQTT_PORT_HTTPS=8444 - MQTT_PORT_HTTPS=8444
- MQTT_ESP_NAME=Garden - MQTT_ESP_NAME=Garden
depends_on: depends_on:
- node-mysql - node-mysql
- node-mqtt #- node-mqtt
restart: always restart: always
ports: ports:
- 2081:2080 - 2081:2080
@@ -32,13 +32,13 @@ services:
volumes: volumes:
- iotdbdata:/var/lib/mysql - iotdbdata:/var/lib/mysql
# for mitko:mqtt # for mitko:mqtt
node-mqtt: # node-mqtt:
image: eclipse-mosquitto # image: eclipse-mosquitto
command: mosquitto -c /mosquitto-no-auth.conf # command: mosquitto -c /mosquitto-no-auth.conf
hostname: node-mqtt # hostname: node-mqtt
ports: # ports:
- 1885:1883 # - 1885:1883
- 10883:1883 # - 10883:1883
restart: always # restart: always
volumes: volumes:
iotdbdata: iotdbdata:

View File

@@ -180,7 +180,7 @@ mqtt_client.on("message", function (topic, message) {
} }
if (topic === EspDeviceName + "/ping") { if (topic === EspDeviceName + "/ping") {
try { try {
console.log("MQTT> processing /ping message. Payload:" + context); //console.log("MQTT> processing /ping message. Payload:" + context);
var data = context.replace(/^\{|\}$/g, '').split('|'); var data = context.replace(/^\{|\}$/g, '').split('|');
var ip = data[4].replace(/"/g, ''); var ip = data[4].replace(/"/g, '');
if (ip != config.gardenIP) { if (ip != config.gardenIP) {
@@ -189,6 +189,7 @@ mqtt_client.on("message", function (topic, message) {
let newConfig = require(configPath); let newConfig = require(configPath);
newConfig[env].gardenIP = ip; newConfig[env].gardenIP = ip;
fs.writeFileSync(configPath, JSON.stringify(newConfig, null, 2)); fs.writeFileSync(configPath, JSON.stringify(newConfig, null, 2));
handled = true;
console.log("Got NEW reporded garden controller IP: " + ip + ". new value stored in persistent settings storage"); console.log("Got NEW reporded garden controller IP: " + ip + ". new value stored in persistent settings storage");
} }
} catch (e) { } catch (e) {