More info: something is definitely wrong with the behavior of WebSession.Quit - and it also appears to be related to whether or not the IDE has “break on exceptions” enabled or not. I’m seeing situations where WebSession.Quit will quit the session, but not the WebApp, and other times the WebApp will quit, too. It seems somewhat random. Anyone dealt with this?
WebSession.Quit is working as expected in Xojo 2015r1 and OS X 10.10.2. The expectation is for WebSession to quit but not WebApplication. Calling Self.Quit in the WebSession.TimedOut event, Session.Quit in a method on a WebPage and Self.SessionAtIndex(AnIntegerValue).Quit in a method on WebApplication all work. None of the WebSession.Quit calls are from WebSession.UnhandledException. Perhaps the issue you’re experiencing is specific to that method and event combination.
If Session.UnhandledException returns False, then the exception is not handled, and the entire app quits.
If Session.UnhandledException returns True, then the exception is considered handled, and the session keeps running.
What I’m trying to do is option 3:
If Session.UnhandledException returns True, then the exception is considered handled and the app doesn’t quit, HOWEVER we want to end the session because something went wrong.
The goal here is to have a somewhat fault-tolerant server : if an individual session dies, the user will be logged off, but the server itself won’t go down.
Testing the project you attached to feedback://showreport?report_id=38390 in Xojo 2015r1 on OS X 10.10.2, WebApplication continues to run regardless of which WebButton is clicked and whether or not Break On Exceptions is checked. While testing, I maintained at least two connections using tabs in Safari 8.0.3, otherwise WebApplication would quit due to the lack of any active connections. In your testing, did you maintain multiple connections to keep the WebApplication running in the IDE?
Session.Quit still seems buggy. I have a CGI app that creates ghost sessions that never die, and Session.Quit does not help. So as advised by Greg a while ago, now I showURL to an HTML page, and the session dies by itself. It work fine. Maybe you can use the same trick ?
Wait… what? A WebApplication quits when it has no sessions active? I know this certainly is not true in standalone web apps - Is this something that only happens in the IDE? Where is this documented? Why?
It does. Otherwise you’d have no default way to quit the app cleanly for profiling and such.
For debugging, we also shortened the time between the last session dying and the app quitting. You can adjust these by setting:
app.Timeout = 60 // Number of seconds to wait after the last session quits before the app itself quits.
app.SessionTimeout = 180 // Number of seconds a session will stay alive after it has lost contact with the client
When you are debugging, these properties are set to 1 and 10 respectively, but you can set them to anything you want. I’d suggest doing it in App.Open though.