Title: Problem with sessions Post by: ClementDoss on February 09, 2015, 12:24:45 AM Hi,
I'm having a very annoying problem with session management. I designed a 3tier application using delphi rtc. The application is running with several clients and one server. After 10 min (or more ) of inactivity, the client freezes. (anyone of them). No matter what I try on the client side, I'm not able to reconnect to the server. Code: HttpClient.MultiThreaded := True; Those events are hooked to the rtcHttpclient: Code: procedure TmdwClient.HttpClientConnectError(Sender: TRtcConnection; The code that freezes the client application is : Code: if not FInGetRows then begin When calling Execute(True,10) the application became responsive. But still the call returns a TimeoutError, which is strange because the server is listening. All other workstations are running fine. But If any of them keep idle for over 10min, the same thing happens. So it's not the hardware. It's me.. again :-\ Let me describe the server side now. This application reads user information from a database, so when opening a session, I must know the user login in order to get the data required by the application. When the session ends, everything is destroyed. This is the relevant server side code: Code: procedure TmdwServer.HTTPserverSessionOpen(Sender: TRtcConnection); There's an important remote function that must be called when the session is created in order to load the user credentials: Code: procedure TmdwServer.fncCheckCredencialsExecute(Sender: TRtcConnection; lBOUser.CheckCredencials( lLogin, lPwd ) will load the user information in my session class (SessionData) that will be used by other remote functions. That's why this function is important. The session ends gracefully, but I don't understand why I can't reconnect the client. Any advice? Clément Title: Re: Problem with sessions Post by: D.Tkalcec (RTC) on February 09, 2015, 12:52:55 AM 1. RTC Sessions have nothing to do with physical connections, so there is no need to close a connection when a Session was closed.
2. By setting the AutoConnect property to TRUE and setting ReconnectOn properties to TRUE, you have configured the Client to re-open a connection as needed. By using "Disconnect", you are effectively disabling the Reconnect feature. 3. The Execute method may ONLY be called from the Main Thread and ONLY from code executed by an action performed by the user. It may NOT be called as a result of ANY events triggered by any RTC component, because it would result in a deadlock. 4. It is a bad idea to assign a Database Session to a Client Session (on the Server), for several reasons. First, because the Server would then require a separate Database Session (=Connection) for every single Client for whom the Server has an open Session. And Secondly, because a new Database Session will be opened for each new Client and Closed every time that Session expires. Normally, you would use a Database Connection Pool for all Database-related tasks on the Server. There are already topics on using and writing Database Connection Pools on the Forum (use the Forum "Search" feature). 5. Use the AutoSessionsPing feature on the TRtcClientModule component to send a PING function to the Server when the Client is idle (not making remote calls). There is already a topic about this on the RTC Forum, HERE (http://www.realthinclient.com/sf/index.php?topic=853.0). Best Regards, Danijel Tkalcec Title: Re: Problem with sessions Post by: ClementDoss on February 09, 2015, 11:34:59 PM Hi Danijel
Thanks to your instructions I managed to solve the problem! :D Clément |