|
Re: How to catch expire session? [message #1833238 is a reply to message #1833135] |
Wed, 07 October 2020 12:24 |
Linuxhippy Mising name Messages: 72 Registered: July 2009 |
Member |
|
|
Hi,
There is no way to notify the user - no connection is active (and non has been for your timeout period), that is the reason the session expired in the first place.
What I did for a high-user-page was to let the clients poll every few minutes (~3minutes), and set a short timeout(6 minutes):
int pollingTimeoutMS = 6*3600*1000; //stop keeping the session alive after 6hours
RWT.getUISession().getHttpSession().setMaxInactiveInterval(180);
String code = ""
+ "var pollStart = Date.now();"
+ "window.setInterval( function() {\n"
+ " if((pollStart + " + pollingTimeoutMS + ") > Date.now()) {"
+ " rwt.remote.Connection.getInstance().send();\n"
+ " }"
+ "}, 150000 );";
JavaScriptExecutor executor = RWT.getClient().getService( JavaScriptExecutor.class );
if( executor != null ) {
executor.execute( code );
}
This will cost a tiny little bit of CPU and bandwidth, however with the benefit of freeing sessions rather aggressivly without impacting the user experience.
[Updated on: Wed, 07 October 2020 12:24] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02606 seconds