NAV 2016 - Limit User Sessions

nickrobbo89nickrobbo89 Member Posts: 10
Hi,

I have recently implemented this code in an Event Subscriber, subscribing to the OnBeforeCompanyOpen event.
The aim is to limit RTC users to one session, as we believe users opening multiple sessions may be having some impact on performance.
IF (SESSION.CURRENTEXECUTIONMODE = EXECUTIONMODE::Standard) AND (SESSION.CURRENTCLIENTTYPE = CLIENTTYPE::Windows) THEN BEGIN
  ActiveSession.SETRANGE("User ID",USERID);
  ActiveSession.SETRANGE("Client Type",ActiveSession."Client Type"::"Windows Client");
  IF ActiveSession.COUNT > 1 THEN
    ERROR(ErrTooManyOpenSessions);
END;

Today whilst testing we ran into a problem. If a users session crashes, and they end the task session with Task Manger, it seems the session is not cleaned up. So therefore the user is left with no session open, but they are unable to access the RTC until someone cleans that session up.

I am wondering if anyone has any suggestions on how to handle this? Or is there an even better way to handle this?

Thanks in advance.
Nick

Answers

  • JuhlJuhl Member Posts: 724
    There is no license issue here, and a user can only click on window at a time.
    I would take my battle elsewhere, hardware first, then analysis using sql profiler, to find the real problem.
    Follow me on my blog juhl.blog
  • aceXaceX Member Posts: 166
    Maybe the better way is to put this code in custom Codeunit where this function will be declared as Subscriber event on Codeunit 1, OnBeforeCompanyOpen event, and also I think there was the kill session code, so maybe when user open new session, always be disconnected from previous.

    Best Regards
  • nickrobbo89nickrobbo89 Member Posts: 10
    Juhl wrote: »
    There is no license issue here, and a user can only click on window at a time.
    I would take my battle elsewhere, hardware first, then analysis using sql profiler, to find the real problem.

    Hardware? Does the hardware really have that much of an impact? I was always under the impression that the network speed is more likely to be the issue than hardware if you have the minimum requirements for NAV?
  • nickrobbo89nickrobbo89 Member Posts: 10
    aceX wrote: »
    Maybe the better way is to put this code in custom Codeunit where this function will be declared as Subscriber event on Codeunit 1, OnBeforeCompanyOpen event, and also I think there was the kill session code, so maybe when user open new session, always be disconnected from previous.

    Best Regards

    This is already in a Custom Codeunit, and I am already subscribing to the event you mentioned. I have modified this, so it prompts the user to confirm if they want to open a new session. (If another session is found). It then loops and kills all the other sessions.
  • JuhlJuhl Member Posts: 724
    Networkspeed is not imported in Rtc to the client. Only between sql and server.
    Everything happens on the server, not the client.
    So yes hardware is important!
    Requirements depends on a lot of things. But disk performance is important for sql and memory for NAV server for caching.
    Follow me on my blog juhl.blog
  • HannesHolstHannesHolst Member Posts: 119
    Hi,


    In terms of performance problem solution, I join the previous speakers in this post.
    There are couple of tools for SQL to retrieve the top10 most performance-hungry statements.

    In regards to the code above,
    it is not possible to identify "lost" sessions from NAV.
    In the ServierTier administration you are able to configure a "Close Inactive SQL Connections". The standard value is 10 minutes. Play a little bit around with it.
    Alternatively search for "session kill" here in the forum.

    Of course, alternatively you could also find out, why your users are forced to end NAV using Task Manager. It's not the normal approach :-)

    Good luck
  • mdPartnerNLmdPartnerNL Member Posts: 802
    I would add a check for a flagvalue in a setup record too. This way a SUPER can override your IF and allow the user (after explaining what the heck they did...)

    Maybe not a flag but let the SUPER relogin. Then check the login time+1 in your IF
Sign In or Register to comment.