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.

It seems like Vaadin Push made the session expired message never appear

Lance Stine
5 years ago Jul 28, 2016 6:05pm

Hello,

I have a web app that push was added to. It seems like about that time the session expired window stopped appearing. Instead the app is unresponsive to anything the user does except a page refresh.

In the javascript console there are messages saying that the wigitset knows that the server is out of session in various ways. There are a lot of them right now. I'm not sure which ones are helpful. Here are some of the messages it logs:

com.mvsc.czrmis.vaadin.widgetset.CombiningWidgetSet-0.js:6510 POST http://localhost:8080/CZRMIS_MAIN/HEARTBEAT/?v-uiId=0 410 (Gone)

WARNING: Heartbeat request returned 410com.vaadin.client.ApplicationConnection

SEVERE: Session expired: null

com.vaadin.client.communication.Heartbeat
INFO: Setting hearbeat interval to -1sec.

com.vaadin.client.communication.MessageSenderWARNING: Trying to send RPC from not yet started or stopped application

I have to use my own implementation of AtmosphereInterceptor to work with the application's framework. I've cut session timeout and heart beat to 1 minute for troubleshooting. Here are some code snipits:
web.xml

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
  <session-config>
    <session-timeout>1</session-timeout>
  </session-config>
</web-app>

Vaadin servlet

@WebServlet(name = "servlet", urlPatterns = {"/*"}, asyncSupported = true,
  initParams = { @WebInitParam(name = "org.atmosphere.cpr.AtmosphereInterceptor",
  value = "com.myorg.MyAtmosphereInterceptor")})
  @VaadinServletConfiguration(heartbeatInterval = 1,
    closeIdleSessions = true, productionMode = false,
    ui = MyUI.class,
    widgetset = "com.myorg.vaadin.widgetset.CombiningWidgetSet")
public final class CzrmisVaadinServlet extends VaadinServlet implements SessionInitListener
...
}

AtmospherInterceptor

public class JpaUtilAtmosphereInterceptor implements AtmosphereInterceptor {
private Logger logger = Logger.getLogger(JpaUtilAtmosphereInterceptor.class);
private final ServerExecutionTimer serverExecutionTimer;

public JpaUtilAtmosphereInterceptor() { }

@Override
public void configure(AtmosphereConfig config) { }

@Override
public Action inspect(AtmosphereResource atmosphereResource) {
  if (Util.getUser() == null) {
    VaadinSession session = (VaadinSession) atmosphereResource.getRequest().getSession().getAttribute("com.vaadin.server.VaadinSession.mysession");
    if (session != null) {
       final User user = (User) session.getAttribute(USER);
       if (user != null) {
         Util.setUser(user.getLoginName());
       }
    }
  }
  return Action.CONTINUE;
}

@Override
public void postInspect(AtmosphereResource atmosphereResource) {
  Util.close();
 }
}

UI class

@PreserveOnRefresh
@Push
@Theme(MyTheme.THEME_NAME)
public final class MyUI extends UI {
... all sorts of things going on here
}

Thanks for any help

Finally, I'm using
com.vaadin:vaadin-server:7.6.4 and the same version for the client, compler, ...etc
com.vaadin:vaadin-push:7.6.4
tomcat 7 and 8 have the same problem

Lance Stine
5 years ago Mar 13, 2017 10:25pm