0

I have had an instance recently were our webserver (host website and app api) turned its toes up and the redundancy did not kick in.

This highlighted a vital missing element of our app which is missing. The App reported 'poor or missing connection' based on XMLHttpRequest.readyState = 0 when infact the server was offline.

Is there a viable method to report if a server is off line or the problem is client end (poor signal)?

Siva K V
  • 7,622
  • 2
  • 11
  • 24
MDP77
  • 53
  • 8
  • 1
    I would use another trusted server that would check the connectivity between itself and the targeted server. This way, you could exclude if the client has a poor connection or not – Cid Feb 14 '20 at 10:56
  • 1
    [//downfor.io/services/api](https://downfor.io/services/api). (a.k.a. downforeveryoneorjustme.com) – tao Feb 14 '20 at 10:56
  • Also contact another website, which is extremely unlikely to be down, like one of the top sites? – trincot Feb 14 '20 at 10:56
  • @MDP77 Detecting server health status is not a good Option. I would encourage you to visit `https://www.downnotifier.com/` for monitoring your health status and respond you to take prompt action – prasana kannan Feb 14 '20 at 11:09
  • instead of pulling you can also think about pushing - let the server notify you that its alive - and if you dont recieve a message within dt better check server state. – Estradiaz Feb 14 '20 at 11:52

1 Answers1

0

The best option is to have another always present and reliable server that monitorizes the non-reliable servers with ping or whatever is necessary. I would use your own server instead of third party because third party can be down, fail or change apis without previous notification.

Althought there are some tricks and network apis that can help like doing ping like in Is it possible to ping a server from Javascript? and reading the error types, however seems to be not very wide-browser compatible sollution or dns queries like in https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/dns/resolve which directly are not compatible with other browsers than Firefox.

user1039663
  • 1,090
  • 1
  • 8
  • 15
  • Dont know why I didnt think of doing that, we have multiple off site servers I can simply perform a loop check in the event of a failure. Thanks for all your comments – MDP77 Feb 14 '20 at 16:26