Project

General

Profile

Detecting Wt "keep-alive"

Added by Drew Dormann almost 10 years ago

Hello,

The Doxygen page for Wt::WApplication mentions this:

keep-alive messages in the background will keep the session around as long as the user has the page opened

How would the client browser be able to query the status of this keep-alive?

I would like to have some client Javascript run if the keep-alive failed - which I imagine would happen if network connectivity went down or the server went away or something similar.

Thanks


Replies (3)

RE: Detecting Wt "keep-alive" - Added by Koen Deforche almost 10 years ago

Hey Drew,

There's indeed currently no way to hook into this --- I believe that would make a nice feature request.

Koen

RE: Detecting Wt "keep-alive" - Added by Drew Dormann almost 10 years ago

Thanks for the reply, Koen.

I imagine that if Wt::WApplication::enableUpdates(true) were being used, a client page could be sent a Javascript timer, calling "disconnected()" in 2 minutes. And every 1 minute, Wt could push new Javascript to the client which resets the timer, effectively postponing the call to "disconnected()" indefinitely.

This wouldn't be elegant, of course, as it would burden the server and not be very responsive. But I think it may roughly approximate this behavior. Would you agree, or do you imagine an issue that would prevent this from working?

RE: Detecting Wt "keep-alive" - Added by Zalu Hobgobicus almost 10 years ago

I think that would work, as long as the client browser can manage a JS timer (a low bar).

You could also have the client page store the last time it got an update, and have a 2-minute timer that gets reset client-side by updates. If an update hasn't happened, then it sends an "are you there?" message to the Wt server, and displays "network issue" if it doesn't get a reply in a reasonable time, but replaces it if/when it does get something. That might be a little less effort per session for the Wt server. Either way, it doesn't seem like a lot of traffic.

Also I wonder if the keep alive results in something that can be detected in clientside JS. Again though, it might vary by browser, and these are putting details in the hands of developers rather than providing a nice Wt-encapsulated method, which is one of the main joys of Wt.

I'd like that feature in Wt, too!

    (1-3/3)