badges / shields

Concise, consistent, and legible badges in SVG and raster format

Home Page:https://shields.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Up/Down Badge works when site is up - not when down

imagelessthought opened this issue Β· comments

Are you experiencing an issue with...

shields.io

🐞 Description

Trying to use the website/up down badge. It works fine when the website is up:

guacamole.unt.edu

But if the server is shutdown: after the timeout it does not show the website down image.

main.guacamole.unt.edu

If I put in fake info - the down image does load correctly.

Website fakesite.invalid

Any suggestions? Thanks. I did try and find a reeference somewhere to the issue, I am sure it is something rather simple - just cannot determien what it is.

πŸ”— Link to the badge

https://imagelessthought.github.io/mainroad/status/

This page has some that I threw on there for testing. It is the secnd one that shows the failure:

main.guacamole.unt.edu

πŸ’‘ Possible Solution

No response

OK, so it looks like if the website instantly responds with an invalid code (e.g: 500) or we get a connection error or whatever, we'll show the down image. If the upstream website fails in a way that just holds the connection open, we'll also just hang waiting.

I think we need to add a timeout to https://github.com/badges/shields/blob/master/services/website/website.service.js (and update the docs).

I'm inclined to make the timeout something like 3.5 seconds to try and keep the whole badge request/response inside the 4 second camo limit.

@chris48s Thanks. I will try and setup a local instance and play around with it. Much appreciated.

@chris48s Would you like me to take out this one?

Yes - feel free. This should hopefully be a one line change 🀞 I just lost sight of it because someone else said they would submit the PR

Sorry, I should have followed up but I assumed someone got to it before me as it stopped generating a an error.

In the description I posted, the button after,
"But if the server is shutdown: after the timeout it does not show the website down image",
was generating an error when I posted it. It was reporting an error when @chris48s responded as well.

But when I went back to check on it and take a shot at resolving the issue, it was no longer generating the error.

When I took a look at the code (website.service.js), I was suddenly enlightened thinking "If a server is shut down, it should not respond at all, why would it keep the connection open?". Your comment makes kinda sense.

But again, in any case server takes a significant amount of time responding, I could still implement some kind of a timeout for it. So, I leave the final decision to @chris48s.

@chris48s, should I go on?

I think it still makes sense to put a timeout on this πŸ‘

I think it still makes sense to put a timeout on this πŸ‘

After completing #9954, will go back to this.