Page 1 of 1

stop all polls on session destroy

Posted: 12 Jan 2014, 16:49
by saraak
Hi
I have a view bean along with UI page say main.xhtml. there is a poll in main.xhtml which sends request to view bean every 30 seconds. I want all main.xhtml pages stop sending request after session expiration eg. after user logout.
I tried to implement this with a SessionListener class but I wasn't successfull. is there any way to handle this situation either with server side code or client side code?
Thanks

Re: stop all polls on session destroy

Posted: 13 Jan 2014, 07:57
by smithh032772
How to redirect to index page if session time out happend in jsf application

click URL above and read BalusC's answer

my opinion/recommendation... do not leave that page in the browser with stopped polling. if session destroyed, then navigate/redirect the page to a session expired or login page.

Re: stop all polls on session destroy

Posted: 06 Sep 2023, 08:04
by luxbaumilinovsky
Late reply, but similar issue!

I have also a poll component on every page which has an intervall of 60 seconds. But with the poll component the HttpSessionListener#sessionDestroyed method will never be called - because there is always an activity! My session timeout is 10 minutes!

So how to distinguish between real activity and activity raised by the poll component?

Re: stop all polls on session destroy

Posted: 06 Sep 2023, 14:21
by Melloware
The short answer is you can't. Your poller is keeping your session alive and will indefinitely.

That is why we also use an idle poller so if the user is off the tab or stops moving the mouse after N minutes we terminate the poller and log them out of the app.

Re: stop all polls on session destroy

Posted: 07 Sep 2023, 07:02
by luxbaumilinovsky
@Melloware: Thanks for your hint! I solved it by using an

Code: Select all

<p:idleMonitor>
, which invalidates my session an redirects to the login page.

Re: stop all polls on session destroy

Posted: 07 Sep 2023, 21:47
by jepsar
Also, you might want to use a web socket instead.