Keep session alive programmatically

asked 2019-08-12 18:09:49 +0800

nicoladileo gravatar image nicoladileo
51 3

updated 2019-08-12 18:11:57 +0800

Hi everyone, I've developed a web application with ZK (8.0.2) + Spring Security, that make use of EventQueue and Threads to execute a long running task in background. I've tried two solutions to prevent session expires while task is still running, but none seems to work:

  1. Make a HTTP request to the server at fixed intervals
  2. Modify WebApp configuration by setting TimerKeepAlive to true

Can anybody suggest me a solutions to fix this issue? Thanks in advance

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2019-08-13 09:47:42 +0800

cor3000 gravatar image cor3000
6034 2 7
ZK Team

Since your descriptions are a bit incomplete it's hard to give you a solution that solves your problem. So instead I'll try to fill in the missing bits with assumptions to line out what should work.

0) Specify a session timeout (in web.xml or zk.xml) you didn't mention which so I'll just assume 5 minutes for this example

1) "make a HTTP request" (that's very vague so I can't comment on that). Just use a <timer> component which will send specific onTimer events to the server at fixed intervals (make sure those intervals are below the 5 mins configured above ... e.g. 2 minutes)

1.1) to verify the timer is firing check your browser's network console, you should see requests to /zkau containing the onTimer events

2) configure <timer-keep-alive> the documentation is quite detailed also mentioning the usage of the timer component

Last ... please test your configuration without spring security first, to verify that it works... then you can test again using spring security. If the config doesn't work anymore, you might have to check and adjust your spring security configuration.

link publish delete flag offensive edit

answered 2019-09-26 21:11:22 +0800

nicoladileo gravatar image nicoladileo
51 3

Thanks, I've fixed removing the subscription of the thread from the event queue

link publish delete flag offensive edit
Your answer
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




Asked: 2019-08-12 18:09:49 +0800

Seen: 12 times

Last updated: Sep 26 '19

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