Increase retry attempts to 10 for all monitor types and enhance timeout error handling to provide detailed failure reasons

This commit is contained in:
Simon Larsen 2024-09-24 16:44:01 +01:00
parent 1d0e7826f9
commit 51334d8a8c
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
6 changed files with 34 additions and 11 deletions

View File

@ -150,7 +150,7 @@ export default class MonitorUtil {
monitorStep.data?.monitorDestination,
new Port(80), // use port 80 by default.
{
retry: 5,
retry: 10,
monitorId: monitor.id!,
timeout: new PositiveNumber(60000), // 60 seconds
},
@ -167,7 +167,7 @@ export default class MonitorUtil {
const response: PingResponse | null = await PingMonitor.ping(
monitorStep.data?.monitorDestination,
{
retry: 5,
retry: 10,
monitorId: monitor.id!,
timeout: new PositiveNumber(60000), // 60 seconds
},
@ -204,7 +204,7 @@ export default class MonitorUtil {
monitorStep.data?.monitorDestination,
monitorStep.data.monitorDestinationPort,
{
retry: 5,
retry: 10,
monitorId: monitor.id!,
timeout: new PositiveNumber(60000), // 60 seconds
},
@ -280,7 +280,7 @@ export default class MonitorUtil {
const response: SslResponse | null = await SSLMonitor.ping(
monitorStep.data?.monitorDestination as URL,
{
retry: 5,
retry: 10,
monitorId: monitor.id!,
timeout: new PositiveNumber(60000), // 60 seconds
},
@ -309,7 +309,7 @@ export default class MonitorUtil {
{
isHeadRequest: MonitorUtil.isHeadRequest(monitorStep),
monitorId: monitor.id!,
retry: 5,
retry: 10,
timeout: new PositiveNumber(60000), // 60 seconds
},
);
@ -350,7 +350,7 @@ export default class MonitorUtil {
requestBody: requestBody || undefined,
monitorId: monitor.id!,
requestType: monitorStep.data?.requestType || HTTPMethod.GET,
retry: 5,
retry: 10,
timeout: new PositiveNumber(60000), // 60 seconds
},
);

View File

@ -187,7 +187,11 @@ export default class ApiMonitor {
`API Monitor - Timeout exceeded ${options.monitorId?.toString()} ${requestType} ${url.toString()} - ERROR: ${err}`,
);
return null; // timeout exceeded
apiResponse.failureCause =
"Request was tried " +
options.currentRetryCount +
" times and it timed out.";
apiResponse.isOnline = false;
}
logger.error(

View File

@ -124,7 +124,13 @@ export default class PingMonitor {
`Ping Monitor - Timeout exceeded ${pingOptions.monitorId?.toString()} ${host.toString()} - ERROR: ${err}`,
);
return null;
return {
isOnline: false,
failureCause:
"Request was tried " +
pingOptions.currentRetryCount +
" times and it timed out.",
};
}
// check if the probe is online.

View File

@ -2,6 +2,7 @@ import OnlineCheck from "../../OnlineCheck";
import Hostname from "Common/Types/API/Hostname";
import URL from "Common/Types/API/URL";
import BadDataException from "Common/Types/Exception/BadDataException";
import UnableToReachServer from "Common/Types/Exception/UnableToReachServer";
import { PromiseRejectErrorFunction } from "Common/Types/FunctionTypes";
import IPv4 from "Common/Types/IP/IPv4";
import IPv6 from "Common/Types/IP/IPv6";
@ -114,7 +115,7 @@ export default class PortMonitor {
logger.debug("Ping timeout");
if (!hasPromiseResolved) {
resolve(new PositiveNumber(timeout));
reject(new UnableToReachServer("Ping timeout"));
}
hasPromiseResolved = true;

View File

@ -88,7 +88,13 @@ export default class SSLMonitor {
`Ping Monitor - Timeout exceeded ${pingOptions.monitorId?.toString()} ${url.toString()} - ERROR: ${err}`,
);
return null;
return {
isOnline: false,
failureCause:
"Request was tried " +
pingOptions.currentRetryCount +
" times and it timed out.",
};
}
// check if the probe is online.

View File

@ -162,7 +162,13 @@ export default class WebsiteMonitor {
`Website Monitor - Timeout exceeded ${options.monitorId?.toString()} ${requestType} ${url.toString()} - ERROR: ${err}`,
);
return null;
probeWebsiteResponse.failureCause =
"Request was tried " +
options.currentRetryCount +
" times and it timed out.";
probeWebsiteResponse.isOnline = false;
return probeWebsiteResponse;
}
if (!options.isOnlineCheckRequest) {