Wakanda 4Dmobile timeout issue

389 views Asked by At

I´m connecting from Wakanda Enterpise v11 to 4D Server using 4D mobile and Connect to Remote Datastore. i respect 60 minute timeout value.

In 4D, on 4D Mobile Authentication Method, all data is fine ($1 contains username and $2 contains password).

When inactivity gets more than 60 minutes and trying to send a wakanda request, on 4D Mobile Authentication Method on 4D $1, $2,.. values are empty and returns "error".

How can I renew/reconnect the connection without restart/reload wakanda sever/model from wakanda server function or how could I set timeout to unlimited?

I´m trying to recover the connection with 4D Server using

  • mergeoutsidecatalog()
  • sending rest request to 4D
  • etc.

Nothing works

5

There are 5 answers

1
walid chafai On

I think that the best thing you can do is, that before you send any request to the server, you test the session expiration.

You can use currentSession(). If it returns "default guest" it means that the session has expired. Then you redirect the user to the login page.

3
Tim Penner On

The documentation for mergeoutsidecatalog() states:

timeout (object-based syntax only): timeout of client connections on the 4D server (pass a number expressing minutes). Each client query that requires a REST access to the external 4D database will create or use a client connection (process) on the 4D server side, keeping the client context. By default, the connection is closed after 60 minutes of inactivity. You can reduce this timeout to 15 minutes, depending on your needs.

So to keep the connection alive you need to send a query before the timeout elapses.

The thing is, once the timeout elapses you cannot call mergeoutsidecatalog() again; it can only be done when the Model object is loaded, so you need to restart Wakanda. This behavior is documented in the mergeoutsidecatalog() documentation:

This method must be called when the current Model object is loaded, that is, in the context of the Model.js file.

Checking the currentSession() may help you isolate when the end-user session has expired, but i dont think redirecting the user to the login page will help since the Wakanda Server will be unable to call mergeoutsidecatalog() without reloading the model (i.e. restarting Wakanda).

If you want the connection between 4D and Wakanda to be maintained indefinitely then you need to either:

a) increase the timeout to a really large number (maybe try 0 to see if it disables the timeout)
or
b) maintain a heartbeat connection to the 4D Server by sending a query before the timeout elapses

1
Eric Naujock On

I recall running into problem along these lines. Check to make sure that your 4D server has a license for Wakanda. I found that the server does not like not having the licenses. Make sure you have 4D Mobile Client licenses on your server. By default you have 0 licenses unless you buy the developer licenses of a set number of seats.

0
northernfrontier On

I would go with it being the license issue. I set my timeout on the mergeoutsidecatalog() call to 5 mins and the Wakanda Session timeouts are by default 60 mins. So my connections to 4D server timeout well before my session times out and I have no problem re-establishing those connections on the next call to a 4D Method by Wakanda. I do this to limit tying up one of my 4D Mobile Licenses any longer than necessary. In my case none of my 4D Mobile Methods are maintaining selections and I am not accessing any 4D tables as data sources in Wakanda, I am only calling 4D Mobile Methods that return Data from other 4D tables in 4D via objects returned by the 4D Mobile Methods. The 4D Mobile Methods all belong to the same table, which contains no actual records.

2
NAMS On

I see you are looking to keep the Wakanda sessions alive.

I believe the solution then is in how the login method is called.

Do you call loginByKey() on the client side, for example, to authenticate a user? loginByPassword() and login() would be the other ways of authenticating from the client side.

I learned that you can supply a lifeTime parameter which is the duration of the session on Wakanda. I don't believe I had success lengthening this on-the-fly, but I set it to a very large value and handle expiring Wakanda sessions manually with waf.directory.logout() on the clientside. (you could use forceExpire() on the server side instead which might be a better way to manually expire sessions)

Here is how to use the lifeTime parameter:

waf.directory.loginByKey(username, pass, 10800)

The 10800 is the lifeTime parameter, which is the max lifetime of a Wakanda session. It defaults to a low number if you don't specify one yourself. I am not sure what unit of time this parameter is. I believe it's in seconds--- 10800 / 60 would be 180 minutes, or 3 hours. If you handle session management well, you can set this to be an exceedingly high number, and just log people out manually. I can advise on this setup as well if this information is helpful.