Thursday, 30 March 2017

Setting session timeout in Glassfish

People complained that their sessions timed-out too quickly in Glassfish.

I checked and it is set to 30 minutes (default 1800 seconds), just a tad too little.

Increased it to 2 hours (7200 seconds).

Just went to Configurations - Web Container - Session Properties - Session Timeout.

It changes the domain.xml:
<session-properties timeout-in-seconds="7200"></session-properties>


Of course, this completely and utterly failed to work in my case.

It turns out I already had a session timeout specified in the web.xml.
The session timeout in the web.xml is specified in minutes.

You can also specify it in the glassfish-web.xml file.1
        <property name="timeoutSeconds" value="600"/>
        <property name="enableCookies" value="false"/>


You do need to check which setting takes precedence in your application. It's not clear from the documentation.


[1] Glassfish 4.0 Application Deployment Guide
iT Geek Help - Glassfish web container tuning settings
StackOverflow - How to set session timeout in glassfish-web.xml configuration file?

No comments:

Post a Comment