irigsoft Posted February 7 Posted February 7 Hello I have a situation where I get sessions that hang (show "please wait" and freeze) while user work. To continue working, the user creates a new session but older stay active. my problem is: I try to close all the sessions in which a given user is registered (one session per user), but this session that is hung is never closed. If this hang is repeated in other sessions, their number increases and the resources they hold too. These "problematic" sessions engage resources on the server, but in them too the components and variables are not destroyed (released), which leads to a problem in the operation of the application. Is there any way with the unigui tools or another way that I can find out which session is hung and turn it off. I thinking about using uniThreatTimer on ServerMOdule to check value of some size (or time) on every session and if this value is bigger , then close it. Is it possible to get some infomation of session ? what is porpose of : - uniSession.IsTerminated - uniSession.AddIdleCounter - UniSession.DisableBlocking - UniSession.GetUniqueCounter - UniSession.IdleTimer can I use it on this situation? Quote
Administrators Farshad Mohajeri Posted February 13 Administrators Posted February 13 Hello, If your session is hung for any reason there is no way to terminate it. A session hangs mostly because of a bug or a runtime error. In some cases it happens because it goes into a dead-lock or an infinite loop. This means that a method or an event never finishes and stays in running state forever. uniGUI can't recover from such situations. The only way is to avoid these situations from happening in the first place. 1 1 Quote
Norm Posted February 14 Posted February 14 “I have a situation where I get sessions that hang (show "please wait" and freeze) while user work……” This statement implies that the browser is waiting for a response from the server that is not forthcoming. This in turn implies that some code is running in an endless loop, either on the server or in ExtJS javascript code. You should be able to use a uniTimer in the main form to guard against such situations. It is standard practice to monitor user idleness and to kill the affected session if necessary. I generally use mouse-clicks and keyboard activity to, via a uniTimer, identify and kill idle sessions. I remember from your previous posts that you do something similar. Why can’t you use this logic to terminate the hanging session. Quote
irigsoft Posted February 14 Author Posted February 14 5 hours ago, Norm said: You should be able to use a uniTimer in the main form to guard against such situations I made a server function using tuniThreatTimer and I check (at runtime) where a session is in an infinite loop, but my problem is that I can't set any variable that I can measure. I'm trying to declare my variable, for example uniMainmodule.SomeDedLockVar and reset it every second, but when that session gets into an infinite loop, I can't get the value of the variable for that session. Now I'm watching the value of unisession.IdleSecs and if it's more than XXXX, then the server closes the session. But I'm not sure if this is the right way to catch a session in an infinite loop. I have timers on session Quote
Norm Posted February 18 Posted February 18 Irigsoft, IMO the uniThreatTimer is the wrong tool for the issue you are having and I would like to suggest a different approach. My suggestion makes the following assumptions based on our description of the issue you are having: The browser is waiting for a response from the server but this is not forthcoming because some code is in an endless loop. Because of above, user actions like mouse-clicks and key-presses are not reaching the server Assuming the above assumptions are correct it seems what you need to do is to recognise the fact that the server has lost contact with the user and force a session termination. To this end I have attached a simple project that works as follows: The ServerModule has a very low session-timeout (2 seconds) Whenever the Session-timeout event fires the timeout value is reapplied to keep the server alive, provided we continue to detect user activity, otherwise the session is allowed to die. As long as there is user activity the main form is pinged every 5 seconds and this fact is used to keep the server alive. The main form uses a timer to measure user idleness and this is used to warn the user of impending termination or, if there is still no reaction within the required period, to signal a session termination. Obviously this solution will only work if the uniTimer continues to fire, which I think is the case, regardless of whatever the endless loop is. I hope this is of some use and that you can adept the idea to at least solve the resource issue you are having. The project uses the following timing values which you can modify Main form ping intervals : 5 seconds Idle seconds before warning the user : 2 minutes Idle seconds before session termination : 4 minutes TimeOutDemo.zip 2 Quote
Abaksoft Posted February 18 Posted February 18 7 hours ago, Norm said: Thank you Norm, In your code, i did not find where is declared Ajaxt Event : _idle_ping ? procedure TMainForm.UniFormAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); begin if EventName = '_idle_ping' then begin fPingCount := 0; lblPing.Caption := '**** WE ARE ALLIVE ****'; fbWarningSent := false; end; end; Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.