diff --git a/api/src/constants/defaults.js b/api/src/constants/defaults.js index 7c79a500..aa2a63cc 100644 --- a/api/src/constants/defaults.js +++ b/api/src/constants/defaults.js @@ -30,9 +30,8 @@ module.exports = { min_area: 0, }, mqtt: { - tls: { - reject_unauthorized: false, - }, + protocol: 'mqtt', + tls: {}, topics: { frigate: 'frigate/events', matches: 'double-take/matches', diff --git a/api/src/util/mqtt.util.js b/api/src/util/mqtt.util.js index a702b62b..abb2623e 100644 --- a/api/src/util/mqtt.util.js +++ b/api/src/util/mqtt.util.js @@ -88,7 +88,8 @@ module.exports.connect = () => { if (!MQTT || !MQTT.HOST) return; try { - CLIENT = mqtt.connect(`mqtt://${MQTT.HOST}`, { + CLIENT = mqtt.connect({ + host: MQTT.HOST, reconnectPeriod: 10000, username: MQTT.USERNAME || MQTT.USER, password: MQTT.PASSWORD || MQTT.PASS, @@ -96,7 +97,8 @@ module.exports.connect = () => { key: MQTT.TLS.KEY ? filesystem.readFileSync(MQTT.TLS.KEY) : null, cert: MQTT.TLS.CERT ? filesystem.readFileSync(MQTT.TLS.CERT) : null, ca: MQTT.TLS.CA ? filesystem.readFileSync(MQTT.TLS.CA) : null, - rejectUnauthorized: MQTT.TLS.REJECT_UNAUTHORIZED === true, + rejectUnauthorized: MQTT.TLS.REJECT_UNAUTHORIZED ? MQTT.TLS.REJECT_UNAUTHORIZED : true, + protocol: MQTT.PROTOCOL ? MQTT.PROTOCOL : 'mqtt', }); CLIENT.on('connect', () => {