Problem with getting session list - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: Problem with getting session list (/thread-1950.html) |
Problem with getting session list - martin.andersen@amesto.dk - 09-09-2020 Hi! In order to let some forms be terminated I get the session list with; gSessions.GetList(alst); as one of the last things in the event IWServerControllerBaseNewSession() in the server control unit But it will almost always not work the second time around, the first time is OK. I've tried to push it to a later time, when the form is up and running (with a timer 5000), but it is the same behaviour. Thx Martin Code: procedure TIWServerController.CleanUpForms(ASession: TIWApplication); RE: Problem with getting session list - Jose Nilton Pace - 09-09-2020 Hi, see this demo, maybe help you: https://github.com/Atozed/IntraWeb/tree/master/15/Delphi/SessionList RE: Problem with getting session list - Alexandre Machado - 09-09-2020 I don't understand what you are trying to accomplish exactly... You said that you are trying to terminate some forms but you are actually terminating some sessions, correct? How's this method called/triggered? From an user event? You are terminating one specific session from another session (i.e. from Session A you terminate Session B)? If so, the code looks good to me, most of it. But the problem relies on the terminate itself. *Don't free the session yourself*. Code: if aid <> ASession.AppID then begin After being terminated, session will be collected by the clean up thread which runs in the background, and freed. If you free it yourself, the clean up thread won't be able to do the proper clean up. RE: Problem with getting session list - martin.andersen@amesto.dk - 09-10-2020 Hi Alexandre! Yes, it is sessions I want to terminate, and yes, terminate session b from session a. I'll try without the free. Thx Martin Hi again, Yes, that worked, I no longer get errors when reading the list. But the list just keeps growing, the sessions are never freed as far as I can tell. I saw from the examples that you can set a parameter on terminate and that is the new HTML it shows. Is that a way to go when wanting the forms in a session to be released, I have some forms with big amount of data on them and those dataset are never freed when the form is not freed. What can I do? Thx Martin Edit: I have put a SessionTimeout := 1; and that triggers the release of my forms after a minute at least. Is there a cleaner way? Code: for aid in alst do begin RE: Problem with getting session list - Alexandre Machado - 09-15-2020 You shouldn't rely on sessions being destroyed to release forms and/or datasets. If you free a form, regardless of the session state, it will be released. The same for datamodules and any other control. Are you leaving the session with active forms? I'll test this scenario you mentioned and let you know. I'll keep you posted. RE: Problem with getting session list - martin.andersen@amesto.dk - 09-15-2020 Thank you for looking into it. Yes, the user just leaves the form, and it is actually replaced by another form usually in an iframe (by replacing the url), so I need to have the session and of cause forms to be release in an automated way. I run with the above technique (timeout=1) now and it works very well, what I could which was that there was a way to just terminate the session and automatically free any forms and resources immediately. I have my data set with Owner = the form, so when the form frees the data is freed also. See the attachment, the IFrame normally points to a ISAPI IntraWeb form with .../$/start/...?companyId=<some id> and the url is just replaced by a new url with a different company id, and therefore the sessions needs to be able to search and terminate the session that was replaced. Thx Martin RE: Problem with getting session list - Alexandre Machado - 09-20-2020 We have a fix in place and a new update should be release soon, which will resolve this problem RE: Problem with getting session list - martin.andersen@amesto.dk - 09-20-2020 Nice, thank you! Will it be a new terminate and free session immediately function? Martin RE: Problem with getting session list - Alexandre Machado - 09-22-2020 Please update to IW 15.2.18. Answering your question: Yes and no. Terminate() never frees the session immediately. It puts it in the list to be collected by the background thread and it will be freed in 60 seconds or less. |