diff --git a/db/patch-add-timeout-ms-monitor.sql b/db/patch-add-timeout-ms-monitor.sql new file mode 100644 index 000000000..f0d07be5a --- /dev/null +++ b/db/patch-add-timeout-ms-monitor.sql @@ -0,0 +1,7 @@ +-- You should not modify if this have pushed to Github, unless it does serious wrong with the db. +BEGIN TRANSACTION; + +ALTER TABLE monitor + ADD timeout_ms INTEGER default 0 not null; + +COMMIT; \ No newline at end of file diff --git a/server/database.js b/server/database.js index b1a23a475..89fe9a717 100644 --- a/server/database.js +++ b/server/database.js @@ -64,6 +64,7 @@ class Database { "patch-add-other-auth.sql": { parents: [ "patch-monitor-basic-auth.sql" ] }, "patch-add-radius-monitor.sql": true, "patch-monitor-add-resend-interval.sql": true, + "patch-add-timeout-ms-monitor.sql": true, }; /** diff --git a/server/model/monitor.js b/server/model/monitor.js index f96b4df06..329c6f05c 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -77,6 +77,7 @@ class Monitor extends BeanModel { weight: this.weight, active: this.active, type: this.type, + timeoutMs: this.timeoutMs, interval: this.interval, retryInterval: this.retryInterval, resendInterval: this.resendInterval, @@ -252,7 +253,7 @@ class Monitor extends BeanModel { url: this.url, method: (this.method || "get").toLowerCase(), ...(this.body ? { data: JSON.parse(this.body) } : {}), - timeout: this.interval * 1000 * 0.8, + timeout: this.timeoutMs, headers: { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "User-Agent": "Uptime-Kuma/" + version, @@ -446,7 +447,7 @@ class Monitor extends BeanModel { } let res = await axios.get(steamApiUrl, { - timeout: this.interval * 1000 * 0.8, + timeout: this.timeoutMs, headers: { "Accept": "*/*", "User-Agent": "Uptime-Kuma/" + version, diff --git a/server/server.js b/server/server.js index 0c9a45e6c..5267f67ce 100644 --- a/server/server.js +++ b/server/server.js @@ -668,6 +668,7 @@ let needSetup = false; bean.headers = monitor.headers; bean.basic_auth_user = monitor.basic_auth_user; bean.basic_auth_pass = monitor.basic_auth_pass; + bean.timeoutMs = monitor.timeoutMs; bean.interval = monitor.interval; bean.retryInterval = monitor.retryInterval; bean.resendInterval = monitor.resendInterval; @@ -1254,6 +1255,7 @@ let needSetup = false; // Define default values let retryInterval = 0; + let timeoutMs = monitorListData[i].interval * 1000 * 0.8; // previously hardcoded in monitor.js /* Only replace the default value with the backup file data for the specific version, where it appears the first time @@ -1278,6 +1280,7 @@ let needSetup = false; basic_auth_pass: monitorListData[i].basic_auth_pass, authWorkstation: monitorListData[i].authWorkstation, authDomain: monitorListData[i].authDomain, + timeoutMs: timeoutMs, interval: monitorListData[i].interval, retryInterval: retryInterval, resendInterval: monitorListData[i].resendInterval || 0, diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 99cbeb95f..ebbe85e22 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -254,6 +254,11 @@ +