Vaadin session time out and UI issue

4.4k Views Asked by At

I'm finding that the Vaadin UI goes grey and becomes inactive and the session expired message is not shown. Also the session does not always timeout after 1 minute, I've set the heartbeat to a higher value than the session timeout so the session should always timeout before a heartbeat keeps it alive.

Here is the config and code I have related to session expiry.

<context-param>
 <param-name>heartbeatInterval</param-name>
 <param-value>240</param-value>
</context-param>

<session-config>
    <session-timeout>1</session-timeout>
</session-config>

<servlet>
    <servlet-name>VaadinExample</servlet-name>
    <servlet-class>com.example.VaadinExample</servlet-class>
    <init-param>
      <param-name>closeIdleSessions</param-name>
      <param-value>true</param-value>
    </init-param>
</servlet>

And in the VaadinExample servlet:

getService().setSystemMessagesProvider(
            new SystemMessagesProvider() {
            @Override 
            public SystemMessages getSystemMessages(
                SystemMessagesInfo systemMessagesInfo) {
                CustomizedSystemMessages messages =
                        new CustomizedSystemMessages();
                messages.setSessionExpiredCaption("Session Expired");
                messages.setSessionExpiredMessage("You have been inactive for over 30mins, click here to reload the application.");
                messages.setSessionExpiredNotificationEnabled(true);
                return messages;
            }
        });

Any ideas?

1

There are 1 best solutions below

0
On

240 1 --> set the timeout to 60 (minutes)

Browser send 1 heartbeats every 240 sec (every 4 minutes). Or your timeout is 1 minute...

If the server doesn't receive 1 heartbeat after 3 attempt (4 min * 3 = 12 minutes) Session will be closed..