ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

timer-keep-alive option does not work

ozkucur
30 Nov 2011 12:55:29 GMT
30 Nov 2011 12:55:29 GMT

We are using the timer-keep-alive option in zk.xml to keep http sessions alive as long as the browser window is open.
But in some situations, we realize that session expires after 10 minutes of inactivity although the browser window was open.
Our questions are:
- Are there any known situations where this timer event is not executed? I.e.: In certain browsers, application servers etc.?
- In case, the timer works as expected, it should obsolete other timeout settings in web.xml or at the application server, correct?
- Can the browser cease to send timer events in case of inactivity?

In short, can we count on this option to control session expiration?

Here is out test environment in detail:

- We are using ZK 5.0.6
- Application Server: WebLogic 11g with cluster (This does not happen on Websphere)
- Browser: Firefox
- In zk.xml, we have
<session-config>
<session-timeout>20</session-timeout>
<timer-keep-alive>true</timer-keep-alive>
...
- In the zul fie, we have:
<timer repeats="true" running="true" delay="1000" onTimer=""/>
- In web.xml, we have
<session-config>
<session-timeout>20</session-timeout>
</session-config>
...

Thanks,
Yetkin

gekkio
30 Nov 2011 19:02:33 GMT
30 Nov 2011 19:02:33 GMT

I can quickly think of two things that might cause the problem:

1. I think you need to invoke timer.start()
I'm not 100% sure about this but in one of my projects we have a working timer and we always invoke start() explicitly

2. It's possible that you need to use a non-empty onTimer listener
I'm not 100% sure about this either, but In our project we make sure that we listen to the event (we call timer.addEventListener("onTimer", ...)

Also, I recommend a shorter timer delay. 1000 causes every user of your webapp to make a request every second.

ozkucur
2 Dec 2011 06:23:50 GMT
2 Dec 2011 06:23:50 GMT

Gekkio, thanks for your tips. we will try them.

zippy
26 Dec 2011 20:40:33 GMT
26 Dec 2011 20:40:33 GMT

i have the same problem

my timer print in console a message (then it works) but the session is closed anyway

i will try with timer.start()

zk ce 5.0.6

benbai
31 Dec 2011 06:40:03 GMT
31 Dec 2011 06:40:03 GMT

I tested some thing about native session, with tomcat at localhost,

zul

<zk>
	<window apply="test.TestComposer" ></window>
	<timer repeats="true" running="true" delay="1000" onTimer=""></timer>
</zk>

composer

...
public void doAfterCompose (Component comp) throws Exception {
  super.doAfterCompose(comp);
    new Thread(new Runnable(){
    public void run() {
      ...
      while (true) {
        Thread.sleep(1000);
        System.out.println(((HttpSession)desktop.getSession().getNativeSession()).getLastAccessedTime());
      }
      ...
    }
  }).start();
}

the last accessed time changed each second as expected,
and it will not changed if remove the timer, as expected.
if there are some other timeout settings depends on native session,
it will never timeout with an activated timer.

Regards,
ben