Configuring session-timeout

Hi everyone,

so I want to configure a timeout for my vaadin application. So I read this page in the documentation:
https://vaadin.com/docs/v13/flow/advanced/tutorial-application-lifecycle.html
And there it states I have to configure that closeIdleSessions = true and some session-timeout parameter.
I’ve tried to find examples but most them are for vaadin 7 or 8. My configuration so far is:

@WebServlet(asyncSupported = true, urlPatterns = "/*")
@VaadinServletConfiguration(productionMode = false, closeIdleSessions = true)
@Component(immediate = true, service = Servlet.class)
public class VaadinServletRegistration extends VaadinServlet 

I can’t seem to find how to pass the session-timeout variable.
Neither the configuration and the webservlet annotation seem to have it defined:
https://vaadin.com/api/platform/13.0.4/com/vaadin/flow/server/VaadinServletConfiguration.html
https://vaadin.com/api/platform/13.0.4/com/vaadin/flow/server/VaadinServlet.html

Could anyone help me find where I should put the session-timeout configuration?

Kind regards,

Sjoerd Brauer

Working with: Vaadin flow (13) & OSGI

Web-server:Jetty

Hello. Maybe i can help a little.
This for WebAppContext:

WebAppContext webAppContext = new WebAppContext();
webAppContext.getSessionHandler().setMaxInactiveInterval(60);

This for VaadinServlet:

@VaadinServletConfiguration(productionMode = false, heartbeatInterval = 10)
@WebServlet(asyncSupported = true, urlPatterns = "/*")
public class VaadinServletExtended extends VaadinServlet {...}

There is need some balance between heartbeatinterval and maxinactiveinterval, as described there:
[https://github.com/vaadin/framework/issues/10898#issuecomment-426667038]
(https://github.com/vaadin/framework/issues/10898#issuecomment-426667038)

Additional:

  • if you close browser with opened early app that will cause the opened sessions will close after about 10 minutes…
  • if you just make some page reloads and it generate some UIs that will cause cloing old UIs after about 30 seconds…

Hey Alexander,

Thanks for the reply, we are not using a WebAppContext in our project. Should I find out how to make one?
Is it possible to declare the session-timeout variable in an annotation or by getting the current VaadinSession.curent()?

Maybe this: ServletContextHandler.getSessionHandler() instead WebAppContext ?
I cannot answer about annotation or VaadinSession.curent() because i was provide an examples from our current project and we haven’t more other.

So I looked into it more deeply thanks to your advice. And it seems I cannot configure the VaadinSession session-timeout parameter. But it’s possible to configure the http-session session-timeout through either using the following code:

VaadinSession.getCurrent().getSession().setMaxInactiveInterval(1);

You can also change the configuration in the web server itself, that what we decided to do now. But it would be nice if this is configerable for vaadinSessions too through the VaadinServlet.