You are viewing limited content. For full access, please sign in.

Question

Question

Refreshing Session properties in SDK Application

asked on February 2, 2018 Show version history

We are currently developing an SDK web application that creates a pool of persistent sessions on startup, which are then "handed out" and utilized as requests come into the server. We got the idea for persistent sessions after Empower as several presenters emphasized the overhead associated with the log in process and we have a constant stream of activity that would benefit from simply maintaining a "constant" connection.

 

So far everything is working as planned, but we wanted to include a step to check that the allocated session is still active, and if not, such as when it has been timed out by the repository, the repository goes down, etc., automatically create a new one to "restock" our session pool.

 

However, what we have found is that the IsAuthenticated and IsConnected property values do not automatically refresh when sessions are disconnected from outside of the application.

 

For example, when our application runs and creates the session pool, if I manually terminate them from the Admin console, when our application checks IsAuthenticated or IsConnected, they both still evaluate as True until we actually try to utilize the session and it encounters and exception.

 

So far, the only way we have found to force a refresh is to try running a process that interacts with the server (currently using Session.GetAllVariables() for testing) within a try-finally to force the properties to refresh before evaluating them; after the exception is handled, the properties reflect that the session is no longer valid and everything works as expected.

 

Is there a better way to determine whether a session is still active/valid without triggering an exception or iterating through everything using a SessionInfoReader instance?

0 0

Answer

SELECTED ANSWER
replied on February 2, 2018

Making a server request in a try/catch is the correct way to test if a session is still alive. When grabbing a connection from the pool, do something like Folder.GetFolderInfo(1, Session). If it fails, dispose of the session object and generate a new one.

2 0
replied on February 2, 2018

Thanks, just wanted to confirm.

0 0

Replies

You are not allowed to reply in this post.
replied on February 2, 2018

Thanks, just wanted to confirm.

You are not allowed to follow up in this post.

Sign in to reply to this post.