Vaadin 7.2.0 Server Push finally working with long polling

We encountered lots of problems with server push either by websocket or streaming. In some networks it was working fine, in others server-client connection was closed after some minutes of idleness. (Heartbeat still working).
We tried getPushConfiguration().setParameter(“timeout”, “-1”);
We tried forcing a push update every minute.
Nothing worked for certain clients.

The long polling mechanism finally seems to work everywhere. We got encouraging feedbacks from clients. So: Thank you vaadin team for implementing long polling!

Glad to hear that :slight_smile: In retrospect, we should have implemented it already in 7.1 instead of streaming…

Your welcome!

Another question: In the debug console on the client side I see the following messages about every 60 secs:

6304466msNo onClose was received before reconnect. Forcing state to closed.
6304473msReopening push connection
6310157msPush connection re-established using long-polling
6369642msNo onClose was received before reconnect. Forcing state to closed.
6369647msReopening push connection
6375334msPush connection re-established using long-polling

The browser on the client side is open on a page, where no changes are pushed from the server (we do manual push). Are these messages from heartbeat (which is scheduled at 60 secs interval)? If not, could you explain? (Especially, if this communication is initiated by the client or the server side).
Thanks a lot.

We had lots of issues with push in 7.1 and turned it off hoping that 7.2 would have it resolved.

Can you share key details about what it means to implement push with long polling?

The key to enable long polling is via annotaion in the UI class:
@Push(value=PushMode.MANUAL, transport=Transport.LONG_POLLING)

We do manual push because we wanted some control of push activity. But we might change this in the future.
It turned out however, that there are still some problems, when a client has the browser open on a vaadin page for hours. We push something to the client at least every 5 Minutes to ensure some activity.

By the way: The reason to switch to server push was, that with the refresher component the client browser consumed more and more memory (without user acitvity) up to the point, where the system reacted very, very slowly.

Hi Guido, could you share a bit more details on the environment where you get the reconnect messages? The browser, the server, whether you have any proxies between them etc. It sounds like something (server/proxy) is timeouting long-living HTTP requests because it does not understand the long polling use case.

Hi Johannes,

I assume you are referring to the lines in my post
6304466msNo onClose was received before reconnect. Forcing state to closed.
6304473msReopening push connection

I get these messages even on my local developement system, so there’s no proxy between.
The components are:

  • Browser is Firefox 29.0.1
  • Server is Apache Tomcat 7.0.42, resp. Apache Tomcat 7.0.26 on the production server
  • web.xml specifies servlet 3.0 and enables async-supported (is in attachment)

So, did I forget to enable something?
14016.xml (2.38 KB)

Hi all!

I`m trying to enable

long polling

push support on tomcat 6. I started with a simple Vaadin 7 project in my eclipse, running tomcat 6.0.39 in it. I changed the Connector to (other configs are default):

 <Connector connectionTimeout="20000" port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol" redirectPort="8443"/>

When tomcat starts it says the NIO protocol is used, but atomsphere throws me an exception, falls back to BlockingIOComet and Push is not working. See log:

May 28, 2014 12:16:15 AM org.atmosphere.cpr.AtmosphereFramework doCometSupport
WARNING: Failed using comet support: org.atmosphere.container.TomcatCometSupport, error: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.You must use the atmosphere-native-runtime dependency in order to use native Comet Support
If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat.jar Is the NIO or APR Connector enabled?
May 28, 2014 12:16:15 AM org.atmosphere.cpr.AtmosphereFramework doCometSupport
SEVERE: If you have more than one Connector enabled, make sure they both use the same protocol, e.g NIO/APR or HTTP for all. If not, org.atmosphere.container.BlockingIOCometSupport will be used and cannot be changed.
java.lang.IllegalStateException: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.You must use the atmosphere-native-runtime dependency in order to use native Comet Support
If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat.jar
    at org.atmosphere.container.TomcatCometSupport.service(TomcatCometSupport.java:77)
    at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1802)
    at com.vaadin.server.communication.PushRequestHandler.handleRequest(PushRequestHandler.java:143)
    at com.vaadin.server.communication.PushRequestHandler.handleSessionExpired(PushRequestHandler.java:176)
    at com.vaadin.server.VaadinService.handleSessionExpired(VaadinService.java:1514)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1415)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:237)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.valves.CometConnectionManagerValve.invoke(CometConnectionManagerValve.java:248)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:891)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:750)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:2283)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

May 28, 2014 12:16:15 AM org.atmosphere.cpr.AtmosphereFramework doCometSupport
WARNING: Using org.atmosphere.container.BlockingIOCometSupport

The app is loading but when calling push(), it throws the same exception again.
Am I missing some more configs?

Thanks a lot! Regards!

Hi,
i have given like below,
@WebServlet(urlPatterns = “/*”, name = “XXXServlet”, asyncSupported = true, initParams={@WebInitParam(name=“pushLongPollingSuspendTimeout”,value=“55000”)})

But sometime in browser, It is taking more than a minute. how to make the push to run with in a min.
I would really proud if anyone given suggestion or solution for this problem

Best Regards,
Pazhani Deva