How to control/kill sessions?Author: Alain Krikilion (alias kriki)
You have 10 users, so you bought 12 sessions (2 extra to be sure). But your users always open multiple sessions.
You have 100 users, but maximum 40 at any time, so you just buy 45 sessions (5 extra to be sure). But your users don’t shut down their PC or don’t close the session when they go home.
In both cases you will have users complaining they cannot log into the system.
There are a lot of ways to avoid this problem. Manually killing those sessions or going to the workstation and closing the sessions or asking the people to close sessions or …. getting those sessions killed automatically using the NAS.
The sessionkiller works with both the Navision database as well as the SQL database but only starting from client version 4.0 (the client must be able to kill sessions by deleting a session in the sessionlist).
Each customer license (at least I think so) has a NAS-session included in it. So why not use it?
How to install the NAS? Well, I am not going to explain that in this How-to. There is a nice how-to which explains how to do that: How To install a NAV Application Server (NAS)?.
The company to which you connect can be any to which the NAS-user has enough privileges to kill sessions.
I’ll give one hint on how to install the sessionkiller:
In codeunit 1, you need to add this code to function “NASHandler” (ID=99):
IF CGNASStartedinLoop = FALSE THEN
CASE Parameter OF
'SESSIONKILLER': CODEUNIT.RUN(CODEUNIT::”Session Killer”);
If you have already a NAS working, you can add it to that NAS by adding parameter “SESSIONKILLER” to its startupparameter.
You can control diverse parameters on how the session killer must work. Run form 80000:”Session Killer Dashboard”.
This form is on table 80000:”Session Killer Setup” and has 2 subforms.
When you change some information on the setup part and your sessionkiller is running, it is possible that sometimes you get an error that the record has been changed by another user. The session killer updates a field in the setup-table when it checks the sessions.
Fields in the upper left side of the form:
“No. Of Licensed User Sessions” This is the number of licensed sessions you bought. When this is 0, the form will get it from the current license, but you can manually update it. It might be useful to put it to a lower number to always have some extra sessions free for users to log in before a new check is done.
“License Per Database” If you have multiple Navision databases (SQL only!), you need to specify if the license is per database or per server. If you have 5 licenses per database, the sessions connected to other databases should NOT be considered by the NAS that controls a certain DB. In case you want to control all databases, you need a NAS per database. In case you DON’T have a license per database, but only on serverlevel, 1 NAS on any database is enough to control all databases.
“Check Every N Seconds” Each how many seconds the NAS must control the sessions. If you add the sessionkiller to other functionality of the NAS, the checktime can increase, depending on the activity of the other functionality.
“Optional Kill Session (Min.)” If a session is idle for longer than this, the session will be killed if there are no more free sessions (“No. Of Licensed User Sessions” - “Current No. of Sessions” < 1).
“Always Kill Session (Min.)” If a session is idle for longer than this, it will ALWAYS be killed, even if there are still free sessions.
“Def. Max. Sessions Per User” give the default number of sessions each user have open at the same moment. 0 means there is no limit. See also below: “Fields in the upper-right subform”.
“Current No. of Sessions” The number of sessions that are in use at the moment.
“Last Check” datetime the sessionkiller did a check.
Fields in the upper-right subform:
In this form, you can define exceptions on field “Def. Max. Sessions Per User”:
“Navision User ID” The Navision USER ID for which to define an exception.
“Maximum Sessions Per User” Number of sessions at the same time this user may have.
Example: You can define that the users may have only 1 session open at any time. But your superuser can have an unlimited amount of sessions. So you define the default=1 and create a record in this subform for each superuser and give field “Maximum Sessions Per User” value=0.
The bottom subform:
This subform is based on table “Session” with a filter on “Idle Time” to show only sessions that are idle for at least 2 minutes and a filter to show only Navision-clients. It is possible to change the filters.
The superuser can also manually kill sessions.
An updated version of the NAV objects has been supplied.