Web Timeout?

Hello all.

I have been unsuccessful with managing the timeout time for a web app. In most cases, I want either a really really long time, like hours. Not at all or somewhere in between. Preferable a variable that can be brought in from a database field setting.

The docs show
App.Timeout = 30

In the Session.Open event I have

Self.Timeout = 54000 // 15 minutes

That does not work…

Can anyone tell me where to put the code, and what code = never disconnect?
And, can the timeout value be a variable?

Thanks all!

You’re talking about two different timeouts. Could you describe exactly what it is that you are trying to prevent?

There are three different timeouts in a web app:

  1. App.Timeout represents the number of seconds after the last session disconnects to when the application itself quits. Defaults to 60 seconds. This value is ignored if you are running a standalone app or if you set App.AutoQuit = False. https://documentation.xojo.com/index.php/WebApplication.Timeout
  2. App.SessionTimeout represents the number of seconds after a user’s browser disconnects from the app that the session is completely removed from memory. This value defaults to 10 seconds in debug mode and 3 minutes (180 seconds) at runtime. https://documentation.xojo.com/index.php/WebApplication.SessionTimeout
  3. Session.Timeout represents the number of seconds that a user can remain idle (no keyboard input or mouse movement) before the Session.TimedOut event fires. https://documentation.xojo.com/index.php/WebSession.TimedOut. Default is zero which means there is no user timeout.

Your code in Session.Open actually sets #3 and if you have not implemented the TimedOut event, it essentially does nothing.

That said, if your intention is to prevent users from ever being disconnected, that’s going to be a hard task in this day and age. The only way for a web app to know if users have “gone away” is to maintain a periodic heartbeat from the browser that basically says “I’m Here”… “I’m Here”… “I’m Here”. What happens in modern browsers is that if the user stops using them, or sends the tab, window or entire browser to the background, javascript and network communications are often paused. That means that the app is no longer communicating with the server and it (rightfully) assumes that the user has gone away.

Thanks for the detailed explanation Greg.

I am trying to use #3, extend the time that the app runs on the browser. Is there some default timeout or rule of thumb that is common across browsers?

Thanks again!

But #3 is not what you are describing. What you’re describing is #2 and that property MUST be set before a session begins to be effective, usually in App.Open.

Nope. Every browser handles it slightly differently.

I’m still not entirely clear as to what the issue is though. You’ve said that you’re trying to extend the time that the app runs on the browser, but not what the conditions are or how long it’s actually working right now.

For instance. I would expect that if you opened a browser window to your app and you were engaged with the app that it would never suddenly disconnect on you (unless the network connection were unstable for an extended period of time).

If however you are putting that browser window into the background and the browser itself is pausing, sleeping or “app-napping” then a disconnect is completely understandable.

Thanks Greg.

I will review the code and help, watch what the timeout is so there are some reasonable answers/data I can provide. I have not really watched it myself so much as having customers request that it stays active longer. But, as you wrote, if they are putting it into the background or something then there is nothing I can do. I think too, my code error is not helping!