0

About Session Timeout

asked 2012-05-31 07:03:51 +0800

beast gravatar image beast
48

Hi All,

I am using ZL Spreadsheet 2.3 OSE, i downloaded ZK Studio plugin and created a new ZK project and used ZK Spreadsheet to open an xlsx file. But Session Timeout message is appearing on screen again and again. I tried following

<session-config>
<timer-keep-alive>true</timer-keep-alive>
</session-config>

in my zk.xml file and following is my index.zul

<?xml version="1.0" encoding="UTF-8"?>

<window title="Hello World!!" border="normal" width="100%"
apply="org.zkoss.zssessentials.generic.composer.SpreadsheetComposer" >
<timer id="timerKeepAliveSession" repeats="true" delay="6000000"/>
<zk>

<hbox>
<button id="exportBtn" label="Export All"></button>
</hbox>
<spreadsheet id="spreadsheet"
showSheetbar="true"
src="/WEB-INF/HelloZSS.xlsx"
maxrows="200"
maxcolumns="40"
width="100%"
height="500px"
></spreadsheet>
</zk>
</window>

i tried your online demo, it was working properly without any timeout message. Please guide me out from this mess.

Thanks in advance

Regards

delete flag offensive retag edit

10 Replies

Sort by ยป oldest newest

answered 2012-05-31 15:09:46 +0800

janfran3 gravatar image janfran3
15

I think the delay to fire event is too long, so the session timeout occure anyway.

janfran

link publish delete flag offensive edit

answered 2012-06-01 03:13:51 +0800

beast gravatar image beast
48

I tried with the delay of one second, but the same result....

link publish delete flag offensive edit

answered 2012-06-01 05:03:29 +0800

beast gravatar image beast
48

got a solution , but not understand the problem yet, when i was running the project from eclipse it was showing session timeout again and again, but when i deployed directly into webapps folder of tomcat it is working fine, but eclipse is also using the instance of same tomcat. Can any one explain why it is so???

link publish delete flag offensive edit

answered 2012-06-01 15:17:34 +0800

zippy gravatar image zippy
504 1 2

You need this

package cl.zippy;

import org.zkoss.zhtml.Messagebox;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.Composer;

public class DoNothing implements Composer{
	 public void doAfterCompose(Component comp) throws Exception {
	        comp.addEventListener("onTimer", new EventListener() {
	            public void onEvent(Event event) throws Exception {
	                //Messagebox.show("alive");
	            }
	        });
	    }

}

and

<timer id="timerKeepAliveSession" running="true" repeats="true" delay="600000" apply="cl.zippy.DoNothing"/>

link publish delete flag offensive edit

answered 2012-06-04 03:16:01 +0800

beast gravatar image beast
48

i tried the do nothing composer but was giving same result when i was running the project from eclipse, but with direct tomcat it was working fine, both with and without do nothing composer

link publish delete flag offensive edit

answered 2012-06-04 04:29:28 +0800

rdgrimes gravatar image rdgrimes
735 7

updated 2012-06-04 04:39:59 +0800

Actually, if I recall correctly, you do not actually need the DoNothing code Zippy suggested.

If memory serves me, the reason you are timing out in your original configuration is because your timer delay was for 6 million ms, which I believe is 100 minutes. I know for Tomcat, the default session timeout is 30 minutes unless you override it in the web.xml. So, your zul timer delay and repeat was never reached at the 100 minute mark, but instead timed out per the default web.xml session timeout. In other words, if your server container defaults to a 30 minute timeout, then by simply changing your delay to 600000, instead of 6000000, it would take effect before your session time's out.

See your original post. You had it at 6000000. In Zippy's "fix" post, it was changed to 600000. That is what, in fact, fixed the problem. The DoNothing code indeed does nothing.

If reducing the zul timer delay does not fix it, then specify, in your web.xml a session timeout that is longer than the zul timer delay, such as:

<session-config>
    <session-timeout>30</session-timeout>
</session-config>

The web.xml uses minutes as the value, while the zul timer delay uses ms. So, careful of the difference.

The DoNothing code was suggested by ZK only for versions 5.0.6 and earlier, just as an FYI.

Ron

link publish delete flag offensive edit

answered 2012-06-04 07:35:58 +0800

gekkio gravatar image gekkio flag of Finland
899 1
http://gekkio.fi/blog

One thing that hasn't been mentioned yet: you need to explicitly activate a setting in zk.xml or onTimer events will not keep the session alive.

Ron, your comments on the session timeout are definitely the core problem here, but I'm still not sure about the dummy onTimer listener.

If we look at ZK source code where the onTimer event is declared:

addClientEvent(Timer.class, Events.ON_TIMER, CE_DUPLICATE_IGNORE);

It is defined with the flag CE_DUPLICATE_IGNORE, but not with CE_IMPORTANT. If CE_IMPORTANT is not used, the client will not send events to the server if there are no listeners. This means that if the dummy listener is not used, the server will never see timer events and the session will time out.

It's possible that there's some special code for onTimer events, but to me it seems that an onTimer listener is needed.

link publish delete flag offensive edit

answered 2012-06-04 14:53:18 +0800

rdgrimes gravatar image rdgrimes
735 7

I would refere to this link (http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/UI_Patterns/Session_Timeout_Management). The use of the timer listener is taken from documentation for 5.0.6 and earlier. The newer documentation that I cited mentions nothing of it.In fact, the only thing I have configured in my project is in zk.xml, web.xml, and then the timer in the .zul page. I don't use a timer listener, and it functions just the way I want.

Here's how I have it:

ZK.XML

	<session-config>  
		<timer-keep-alive>true</timer-keep-alive>
	</session-config>

WEB.XML

	<session-config>  
		<session-timeout>30</session-timeout>
	</session-config>	

*.ZUL

                     <timer id="timerKeepAliveSession" repeats="true" delay="600000"/>

That's it, nothing more, and it doesn't timeout on me.

link publish delete flag offensive edit

answered 2012-06-04 14:57:31 +0800

rdgrimes gravatar image rdgrimes
735 7

One more thing. You don't mention much about your environment. But, be aware that timeouts can exist at multiple levels: your desktop browser, your WAF (if you have one in place), the war container (Tomcat, Websphere, etc.), your PIX (again, if you have one).

link publish delete flag offensive edit

answered 2012-06-05 04:33:39 +0800

beast gravatar image beast
48

I think that was issue related to my environment....but now it is working fine with tomcat 6.0.26. Thank you all for your help and suggestions.

Regards
Beast

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-05-31 07:03:51 +0800

Seen: 430 times

Last updated: Jun 05 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More