Skip to content

Commit

Permalink
Fix: Fix no certificate caused by session reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
cch-aecomhk committed Jul 23, 2021
1 parent f20ab4b commit 4d262bb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions server/model/monitor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

const https = require('https');
const dayjs = require("dayjs");
const utc = require('dayjs/plugin/utc')
var timezone = require('dayjs/plugin/timezone')
Expand All @@ -10,6 +11,12 @@ const {R} = require("redbean-node");
const {BeanModel} = require("redbean-node/dist/bean-model");
const {Notification} = require("../notification")

// Use Custom agent to disable session reuse
// https://github.com/nodejs/node/issues/3940
const customAgent = new https.Agent({
maxCachedSessions: 0
});

/**
* status:
* 0 = DOWN
Expand Down Expand Up @@ -70,8 +77,9 @@ class Monitor extends BeanModel {
if (this.type === "http" || this.type === "keyword") {
let startTime = dayjs().valueOf();
let res = await axios.get(this.url, {
headers: { 'User-Agent':'Uptime-Kuma' }
})
headers: { "User-Agent": "Uptime-Kuma" },
httpsAgent: customAgent,
});
bean.msg = `${res.status} - ${res.statusText}`
bean.ping = dayjs().valueOf() - startTime;

Expand Down

0 comments on commit 4d262bb

Please sign in to comment.