How long does it take an application running as a headless client to shutdown after it executes the
application.exit()
method?
In my case it never seems to do so.
IS there some setting that can be adjusted to shorten the shutdown time if there is such as setting?
Tom
Servoy 3.5.9
Headless client is basically JSP using “servoy aware” beans, so I guess that the timeout for a client session is the default used by Tomcat, which is 30 minutes.
You could lower that timeout by altering your web.xml file located in /Servoy/application_server/server/webapps/ROOT/WEB-INF/
with something like (unit is minutes):
<session-config>
<session-timeout>10</session-timeout>
</session-config>
before the ending tag.
So in the example above, I have shortened the session to 10 minutes.
Be aware though, that by doing so you are shortening the life span of a session, meaning that if a user leave its browser open and go grab a coffee and start chatting with a colleague… if there is no browser activity for +10 minutes, his session will be lost (meaning that he will probably need to authenticate again, and if he was on a form and had began some editing, all his changes will be lost).
There are workaround for this, like using Ajax to periodically “ping” the server if the browser is still open, or having an invisible frame with a meta-refresh or a javascript which updates the page every 9,5 minutes.
I do it like that on all my web developments and I have people connected for hours on my system from the early morning to the evening with an hour lunch inactivity, if they leave their browser open, they keep their session open, if they don’t then the session is closed after only 10 minutes (which is quite low in web standards).
Hope this helps,
Thanks Patrick for an explanation ![Crying or Very sad :cry:]()
I am not skilled in JSP but knowing this little makes me wish for more fundamental methods available in the Servoy baseline as opposed to having to go get third party plugins or worse to make one’s own!
My objective is to be able to shutdown a headless client once I have it finish its job. I thought that application.exit() would do that immediately rather than have a dependence on some other exotic factor.
I cannot of course have the session cut short like in your example.
My headless client only takes a few seconds at most to do its job, so I want it to cease to exist at that point.
I shall look at other ways to achieve my goal perhaps without having to use a headless client at all if I cannot find a way to kill the headless client or have it shut down by itself (quickly).
If you trigger yourself the disconnection, in the headless JSP, you could try “session.invalidate()” to close the session.
Believe me, it’s not that exotic ![Wink ;-)]()
Personnaly I use the following code when I want to stop my headless client ```
session.setAttribute(“servoy”,null);
I don't know if it really kills the headless client or simply re-initiate it to null (and then kills it after the timeout) but it works fine for me. The headless client disappear straight from the connected clients list
Sure, it should work equally fine. I just prefer session.invalidate() because it not only releases the Servoy session but also the Tomcat session as well…
Be nice to your server it will be nice to you in return ![Wink ;-)]()