#1 2019-05-08 14:06:37

Kixemi
Member
Registered: 2017-02-10
Posts: 10

SilentLogin from Web or Crossplatform interface type client

Hello

From my Android client I would like to do a silentlogin if sessiontimeout has expired.
When I do a query from client to the interface I sometimes because of different reasons get a 403 Authentication failed!
This because of the session timeout has expired.

In these cases I want to do a fast silentlogin and directly after send the endpoint call again.

The code below does not work, but perhaps you get the ide'e what I am getting!

            try
              rstRequest_mORMot.result := aTIMSDriver.GetRoutes(routemonitor_str, day_str, DriverToFetch, ''); // Normally I get a answer here, but sometimes i get invalid session signature.
            except on e: EServiceException do
             begin
                //so then I must create a "new" connection and new session signature
                aTIMSDriver.Client.Free;
                FAppData.Client := GetClient(FAppData.FTimsURL,FAppData.FLoginName,FAppData.FLoginPassword,StrToInt(FAppData.FTimsPort));
                aTIMSDriver.Connect;

                // And now I excecute the "orginal" query again
                rstRequest_mORMot.result := aTIMSDriver.GetRoutes(routemonitor_str, day_str, DriverToFetch, '');  // ...And get the answer I wanted to begin with...
           //   end;
             end;
            end;
          end

How is this done, is there a reconnect or something?

Offline

#2 2019-05-08 14:54:53

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: SilentLogin from Web or Crossplatform interface type client

Please define "does not work"...

The easiest is to put a higher session timeout delay.
Or call the server regularly, as is done with a Delphi client.

Offline

#3 2019-05-08 15:50:41

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 337

Re: SilentLogin from Web or Crossplatform interface type client

I use OnAuthenticationFailed event for automatic relogin


Esteban

Offline

#4 2019-05-08 16:33:00

Kixemi
Member
Registered: 2017-02-10
Posts: 10

Re: SilentLogin from Web or Crossplatform interface type client

Hi Ab
After i get "Authentication failed, Invalid signature(0)" I want to create a new connection on the fly in order to get a new valid signature and a new session on server side.
My "old" or "current" signature on the client side that reside inside the mORMot Crossplatformobjects, is not to be found anymore on the "BackEndServer" beacause of the session timeout there.
So now I want to recreate, or create a new session with the backend server. I tried to do it in the same way as I do it on client/program startup, but I think the problem is that I cant get rid of all the old CrossPlatformObjects.
I have tried aTIMSDriver.Free and FAppData.Free, but they gives me an errors... I cant get the cleanup done before creating a new session.
If i only call aTIMSDriver.Connect (without any Free:ing before that) it says that I already have a connection, and I cant create a new one.. and that would be a memory leak also..
In the code below

                aTIMSDriver.Client.Free;
                FAppData.Client := GetClient(FAppData.FTimsURL,FAppData.FLoginName,FAppData.FLoginPassword,StrToInt(FAppData.FTimsPort));
                aTIMSDriver.Connect;

I get the error described below from the aTIMSDriver.Connect row:
-errorcode 401
-sicClientDriven instance not found or deprecated for TIMSDriver.Connect

I have all the mORMot communication code inside a tread on the client side, can that be a problem, to Free the objects there..

To set a longer session timeout is perhaps a solution, but how long sessions are Ok, maybe is some cases the Android phone is without internet connection for many hours, and the session will then not be prolonged.
Is it ok to have a 24 hour session timeout?

Esteban,
can you show some code example on how to implement the OnAuthenticationFailed event, code to create that event handler and code to put for the relogin?


Best Regards Kim

Last edited by Kixemi (2019-05-08 16:37:08)

Offline

Board footer

Powered by FluxBB