glanceapp / glance

A self-hosted dashboard that puts all your feeds in one place
GNU Affero General Public License v3.0
8.59k stars 299 forks source link

Feature Request: Monitor Site Property Timeout & Retry #144

Open samcro1967 opened 5 months ago

samcro1967 commented 5 months ago

I have one IoT device that takes about 20 seconds for the site to load in a browser. In Glance, it always shows as error when setup in a Monitor Widget. Would it be possible to add a timeout value for a site setup in a monitor widget to be able to specify a timeout value so that it waits for a user specified time before reporting it as an error? Might also make sense at the same time to also add a retry value so it could be tried 2 or 3 times before reporting as an error.

svilenmarkov commented 5 months ago

Hey,

The issue with this is that the entire page becomes visible only when all widgets are done loading. If you were to set the timeout to 20 seconds and had 3 retries, you're potentially going to be staring at the loading indicator for a whole minute. I went with this approach rather than displaying each widget when it's done loading because I didn't want things to jarringly jump up and down as widgets load one by one (layout shifting).

Technically this can be done for the monitor widget since the height of each site is constant so it shouldn't result in a layout shift, though I don't currently have the required functionality in place to be able to do this easily.

Would it help if you were able to choose the method of the request that the widget makes? It does a GET request currently which fetches the headers and body, if you were to change it to a HEAD request it would only fetch the headers, meaning there's less data being sent so in theory should load much more quickly, assuming the site you're checking has an endpoint that supports HEAD requests.

samcro1967 commented 5 months ago

Being able to change the default request type to a head should do the trick. I have tested a couple of IoT devices that are failing the get request from time to time and they both seem to support a head request. Example of one is below.

curl -I -k https://192.168.1.122:8080/ui/
HTTP/1.1 200 OK
Content-Type: text/html
Accept-Ranges: bytes
ETag: "2365067868"
Last-Modified: Mon, 11 Oct 2021 09:00:13 GMT
Content-Length: 202279
Date: Mon, 24 Jun 2024 16:17:46 GMT
Server: <redacted>