Skip to content

Commit

Permalink
Increase retry attempts to 10 for all monitor types and enhance timeo…
Browse files Browse the repository at this point in the history
…ut error handling to provide detailed failure reasons
  • Loading branch information
simlarsen committed Sep 24, 2024
1 parent 1d0e782 commit 51334d8
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
12 changes: 6 additions & 6 deletions Probe/Utils/Monitors/Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand All @@ -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
},
Expand Down Expand Up @@ -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
},
Expand Down Expand Up @@ -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
},
Expand Down Expand Up @@ -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
},
);
Expand Down Expand Up @@ -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
},
);
Expand Down
6 changes: 5 additions & 1 deletion Probe/Utils/Monitors/MonitorTypes/ApiMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 7 additions & 1 deletion Probe/Utils/Monitors/MonitorTypes/PingMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion Probe/Utils/Monitors/MonitorTypes/PortMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion Probe/Utils/Monitors/MonitorTypes/SslMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion Probe/Utils/Monitors/MonitorTypes/WebsiteMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 51334d8

Please sign in to comment.