Polling and Session Timeout

I am trying to create an application with a session timeout of 10 minutes. However, my session is being kept alive by Vaadin’s polling, which I have set to 30 seconds.


VaadinServlet.service
Is there any way I can use polling and still have sessions timeout? Is there anything in the request in that I can use to differentiate a poll from all other requests?

If the [tt]
closeIdleSessions
[/tt] servlet parameter is “true”, the session expires after the time specified with the [tt]
session-timeout
[/tt] parameter, if there are no other but heartbeat request. See
here
.

Thank you Marko.

I am not able to use web.xml for my servlet configuration, so I am doing it in the following way:

@VaadinServletConfiguration(ui = UI.class, productionMode = false,
heartbeatInterval = 500, closeIdleSessions = true)
public class MyVaadinServlet extends implements SessionInitListener {

@Override
    protected void servletInitialized() throws ServletException {
      super.servletInitialized();
      getService().addSessionInitListener(this);
    }

    public void sessionInit(SessionInitEvent event) throws ServiceException {
        event.getSession().getSession().setMaxInactiveInterval(1000);
    }
}

Unfortunately, with this setup the session never expires when polling is set. Is there something I’m missing that I need to make this work?

I noticed that in VaadinServlet.service I can use request.getPathInfo(). For a hearbeat this returns /path/HEARTBEAT. From what I’ve read, it returns /path/PUSH for a push (I am not able to use either push or icepush in my servlet, polling is the only option). However, a poll returns /path/UIDL, which is the same as almost all other requests that come through the method. There must be some other way to determine if it is a poll request, so then at least I can manually control session timeout?

Might be related to
this thread
and maybe
this ticket
.

The closeIdleSessions parameter only concerns heartbeat. Unfortunately polling does not currently include corresponding logic to force the session to close even though the polling would otherwise keep it alive indefinitely.

Thank you both. I think I have found a way around this, but just out of curiosity is adding logic to handle session timeout to polling planned for a future release?

I can’t get session timeoput to work with polling.

Session timeout works as expected and can be controlled by setting
VaadinSession.getCurrent().getSession().setMaxInactiveInterval( xx );

But now my UI need polling so I do setPollInterval( 5000 );

Both the above in my UI.init()

And when polling gets enabled session timeout stops working, this has been discussed a lot over the past years but i still cant find a working workaround

I have Vaadin 7.6.7 bootet by spring boot , no web.xml and none of my classes extending VaadinServlet

Rgds Lars

Hi, it is the com.vaadin.server.communication.ServerRpcHandler#handleRpc that falsely prolongs the user session by calling ui.getSession().setLastRequestTimestamp(System.currentTimeMillis()) for all RPC requests, including poll requests (requests that contain poll invocations). It is also important that there may be other requests initiated by the poll request (e.g. lazy update of component’s data) which need to be ignored too. ServerRpcHandler (and UI, …) classes can be patched to make this work.