Sphvn
Sphvn

Reputation: 5353

Rest / HTML - If server stops detect if server starts again?

Something I am playing with at the moment is a Rest / HTML page that dynamically updates via JSON calls.

Now in the case that I want this to run on as low a bandwidth as possible.

So if the server is shut down, then booted up again I want the updates to continue again in most cases this works some cases parts of the javascript won't work and it times out.

So what is a low overhead solution to detect that the Server has started up again?

(Looking for good ideas or other methods to do this)


thoughts:
So far I have thought of having a status request but this uses bandwidth again to continually run?

Or how to only run this status request once the server had gone down and stop when its up?

Upvotes: 0

Views: 91

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039298

You could use the setInterval function to continuously poll the server for updates. Once a request fails you could enter a so called safe-mode by sending only HEAD requests (and as suggested by @sje397 also increase the timeout interval) to reduce bandwidth and once it succeeds you enter again normal mode and continue with GET/POST.

There are also more exotic things like COMET and Web Sockets in HTML 5 that allow the server to push updates to the client.

Upvotes: 3

Related Questions