Broken links monitor - timeout error

Hello, I have created a synthetics broken links monitor, but for some of the links i am getting socket hangup -101 or connection timeout -118 status code and it fails the script. but when i check the links manually they load so the link is not actually broken.

  1. Is there a way i can add more timeout? or we can exclude these error status in assertion?

or 2) how do it in scripted browser?

Thank you.

Hey @autoqal90,

Thanks for your question about customizing the broken links monitor. There isn’t currently a way to add a timeout or assertion. You’re right to assume you’d need a scripted browser or api test monitor to do that.

In a scripted browser, you could add a timeout like:

$browser.get("https://synthetics-horde.nr-data.net/synthetics/api/v1/ping")
  .then(function () {
    $browser.sleep(5000)
})

Since build 3.0.46 of the CPM, scripts will no longer fail on 4xx/5xx response codes. You’ll need to use an assert to fail on those. For example, an api test monitor can use the assert module to validate results:

  // catch the "TypeError: Cannot read property 'statusCode' of undefined" error
  assert(response != null, "no response received")
  console.log("response.statusCode: " + response.statusCode)
  assert(response.statusCode === 200, "Expected 200 OK response")

The assert module can be used in all “scripted” runtimes.

Here’s a useful post from an external site that describes what you’re trying to do.
https://www.browserstack.com/guide/how-to-find-broken-links-in-selenium