Atmosphere/atmosphere — Issue #66: AtmosphereGwtHandler.doComet/HttpSession timeouts
Author: jurjenvg
Created: 2011-11-16 08:05:13+00:00
State: open

When overriding AtmosphereGwtHandler.doComet the following difference can be observed between Servlet 3.0 Async and Grizzley comet, using Glassfish 3.1.1, Oracle JDK 7, GWT 2.4, Atmosphere 0.8.0-RC3.

Let TIMEOUT be the value returned by the override of AtmosphereGwtHandler.doComet. On Grizzley, a connected GWT client calls doComet approximately every TIMEOUT milliseconds. On Servlet 3.0 async, AtmosphereGwtHandler.doComet is called only once. The result is that despite setting org.atmosphere.cpr.sessionSupport to true in web.xml, HttpSessions timeout using servlet 3.0 async if no other requests touch a user's session. My ugly workaround for Servlet 3.0 async is to put an otherwise bogus rpc call in AtmosphereListener.onHeartbeat() as given below. I expected that setting org.atmosphere.cpr.sessionSupport to true would keep my user's sessions alive, as documented on the successor project.

@Override
public void onHeartbeat() {
Client.sessionService.touchSession(new AsyncCallback() {
@Override
public void onFailure(Throwable caught) {
log.warning("HttpSession touch failed, the danger of timeout exists");
}

@Override
public void onSuccess(Void result) {
log.fine("HttpSession touched to prevent a timeout");
}
});
}