mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-28 01:04:05 +00:00
fix protocol not defined bug
This commit is contained in:
parent
d3c90df8a8
commit
4118de6d53
1 changed files with 4 additions and 0 deletions
|
@ -94,6 +94,10 @@ exports.mqttAsync = function (hostname, topic, okMessage, options = {}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const { port, username, password, interval = 20 } = options;
|
const { port, username, password, interval = 20 } = options;
|
||||||
try {
|
try {
|
||||||
|
// Adds mqtt protocol to the hostname if not already present
|
||||||
|
if (!/^(?:http|mqtt)s?:\/\//.test(hostname)) {
|
||||||
|
hostname = "mqtt://" + hostname;
|
||||||
|
}
|
||||||
let client = mqtt.connect(hostname, {
|
let client = mqtt.connect(hostname, {
|
||||||
port,
|
port,
|
||||||
username,
|
username,
|
||||||
|
|
Loading…
Reference in a new issue