Skip to main content

At User Support we occasionally get questions about the termination of WebUI sessions; for instance as follows:

We have a project where the premaintermination and maintermination both contain the statement “return 1”.

Separately, we have a library in which we want to run some checks and empty some parameters in the library pre termination. However, we observe that when the app is uploaded, the PreLibraryTermination and LibraryTermination are not ran.

We’ve noticed this because when re-opening the same app within a few minutes, the data session is still active, and parameters that should be empty because we empty them both in the library initialization and termination, still contain data.

 

Understandably, if you are not aware of the termination protocol of AIMMS WebUI sessions, this can be confusing.

Let me share some details about the termination protocol for an AIMMS WebUI session first:

  • Background: An AIMMS WebUI session consists of two communicating processes:
    • A process in the browser of the end-user interacting with that end-user
    • A process running on central hardware of the AIMMS PRO system, computing values as prescribed by the AIMMS model. I call this the data session.
  • Observation: When an end-user closes the browser tab containing the visuals of an AIMMS WebUI session, this can be accidental or on purpose.
  • Choice: When this tab-close is accidental, the end-user has five minutes to recover by launching the same application again from the AIMMS PRO portal; the AIMMS data session will reconnect such that the end-user has access to latest data again.
  • Choice: When this tab-close is on purpose, the data session ends silently after five minutes. When the data session is ended, the termination procedures are ran.

There are several ways to alter this protocol:

  • The timeout of five minutes can be adapted, see https://how-to.aimms.com/Articles/342/342-WebUI-Session-Timeout-Extension.html
  • An admin of AIMMS PRO can terminate the data session via the AIMMS PRO portal, tab configuration > active data sessions.
  • Adding a "bye” button, which, when clicked, ends the data session. Note that the browser tab of the WebUI session is not closed, but its contents are replaced by the AIMMS PRO portal.

A "bye” button can be implemented as follows:

First add the procedure pr_goodBye to the application defined as follows:

Procedure pr_goodBye {
    Body: {
        if pro::GetPROEndPoint() then
            if DirectoryExists("./MainProject/WebUI") then
                pro::sessionmanager::FinishSession(); ! Stopping data session of a published WebUI application.
            else
                ExitAimms(); ! stopping data session of a published WinUI application.
            endif ;
        else
            ExitAimms(); ! Stopping a session being run in AIMMS Developer.
        endif ;
    }
    Comment: "Stop data session via the door at the far lower right corner.";
}

As it is your project, you can, of course, adapt the above to your needs, for instance to start by verifying that all data is saved.

Then link the procedure pr_goodBye to a button titled "Bye” in the WebUI, or use the status bar by adding the following data to it:

('9', 'header'    ) : "",  
('9', 'icon' ) : "aimms-exit",
('9', 'color' ) : "",
('9', 'text' ) : "Bye",
('9', 'tooltip' ) : "",
('9', 'procedure' ) : "pr_goodBye",
('9', 'state' ) : "Active"

which will give the impression of an exit door in the lower right of the screen:
 

Use the exit at the lower right to exit the app

 

Hi ​@Chris Kuip,

Thanks for the post. One question though, when I try to link the procedure with a button it works fine, but when I use the same procedure on the status bar I get the following error:

awf.data.aimms.session:Running procedure 'pr_logout' has resulted in an error: No authorization to run procedure pr_logout (code=500)

Any idea?

Gorkem


I get a similar error message when I make a typo in a procedure name, or when the procedure is declared in a module or library (a prefix is needed in that case).  Can you check the spelling again?

If the above does not resolve the issue at hand; please report it to support@aimms.com.


I get a similar error message when I make a typo in a procedure name, or when the procedure is declared in a module or library (a prefix is needed in that case).  Can you check the spelling again?

If the above does not resolve the issue at hand; please report it to support@aimms.com.

Hi ​@Chris Kuip , Thanks for the reply. That was my silly mistake. It was expecting for the prefix of the procedure’s library, although the string parameter for the status bar is also in the same library. So instead of “pr_goodBye”, it should have been like “ul::pr_goodBye”. 

 

I have another question though. The procedure pr_goodBye seems to be killing the session indeed. However, it takes around 1 minute until the same user is able to launch the app again, and during that time the user gets the following error report on their browser:
 

Afterwards, everything gets back to normal again and they can re-launch a new session.

Any idea on this?

Best,

Gorkem


Hmmm, I was not able to reproduce your claim when running on AIMMS Cloud.

I tried several times, but I have to admit I waited until the app browser window was replaced by the portal page. 


Reply


Didn't find what you were looking for? Try searching on our documentation pages:

AIMMS Developer & PRO | AIMMS How-To | AIMMS SC Navigator