Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Polling and Session Timeout

Patrick O'Brien
9 years ago Feb 22, 2014 2:53am
Marko Grönroos
9 years ago Feb 24, 2014 9:06am
Patrick O'Brien
9 years ago Feb 24, 2014 3:01pm

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?

Marius Reinwald
9 years ago Feb 24, 2014 3:07pm
Johannes Dahlström
9 years ago Feb 24, 2014 3:24pm
Patrick O'Brien
9 years ago Feb 25, 2014 8:27pm
Lars Worsaae
6 years ago Jul 21, 2016 12:48pm

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
 

Peter Martinovic
3 years ago Jul 31, 2019 2:25pm

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.