Push problem when recovering from server restart

Our Vaadin app is using Atmosphere push with websockets and we’re trying to recover from server restarts. If the server restarts while a user is logged in there’s not much that can be done. However, when the server retarts and the user uses the browser instance (does not close and reopen) they get directed to the wrong URL.

Expected:
http://localhost:8080/site/auth

But get this:
http://localhost:8080/site/auth/PUSH/?v-uiId=0&v-csrfToken=3f1213b9-97d4-4020-ad19-db0ddbedb627&X-Atmosphere-Transport=close&X-Atmosphere-tracking-id=0af08070-7399-43f9-b2d9-be2199464219&_=1433955068111

Some debugging with UrlRewriteFilter shows the new URL is http://localhost:8080/site/auth/PUSH/PUSH/ which is one too many PUSH directories.

Is there a way I can clean this up when the server restarts? Maybe through JavaScript? Using UrlRewriteFilter rules just creates an endless loop.

My company ended up going through vaadin Pro services. There’s an aknowledged issue here but they gave us a workaround.

Create a filter in your web.xml

<filter>
    <filter-name>RequestFilter</filter-name>
    <filter-class>com.mycompany.servlet.ApplicationRequestFilter</filter-class>
</filter>

Then create the class you reference in the web.xml and extend javax.servlet.Filter. Override the doFilter(…) method. Here’s what ours looks like.

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
String transport = request.getParameter(“X-Atmosphere-Transport”);

if (transport != null && transport.equals("close"))
{
    String contextPath = ((HttpServletRequest) request).getContextPath();
    ((HttpServletResponse) response).sendRedirect(contextPath);
}
else
{
    chain.doFilter(request, response);
}

}