web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AOS crashes on max session Id (65535)

(1) ShareShare
ReportReport
Posted on by 524

The admins of my current assignment routinely monitor the highest session id and when it comes near the 60k mark they reboot the AOS so that the numbering starts from scratch. Rather inconvenient since this happens during operation hours.

The reason for this is that apparently the lights go out when the session id hits 65k: AOS crashes. 

So, if I interpret SP CREATEUSERSESSIONS correctly, then it does appear to increment session ID's until it hits the magical number of 65535 (FFFF), after that it no longer returns a session ID, but returns -3 which I assume is an error-code.

All fine and dandy, but if this was the case then I surely would have encountered it before and at least half the community here would show up on Microsoft's parking lot with torches and pitch forks. So I'm sure I'm missing something here (please don't say SQL skills!) and my interpretation of the SP falls short.

Now the FFFF-doom scenario only occurs when 

  1. if (select count(*) from SYSCLIENTSESSIONS where SESSIONID IN (@first)) > 0
    1. @first is the lowest session ID that is greater than @maxclientId and not the @masterid
  2. @sessionid = -1 or @licenseType = 0

I guess I could write these parameters to a temp table, but at the moment I only have access to the PRD environment and there are limits to my level of confidence.

So my questions:

1. Does anyone know what the parameters @maxclientId and @licenseType represent?

2. Does anyone know why the AOS would crash upon session ID -3?

3. WTF? Why does it not reuse available session ID's? (two questions, but please only answer the 2nd one)

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    299,407 Super User 2025 Season 2 on at
    RE: AOS crashes on max session Id (65535)

    Hi Francesco,

    The maximum number of sessions can be set per AOS: docs.microsoft.com/.../application-object-server-aos-configuration-commands. However, 65535 is the maximum. This will explain the @maxclientId parameter. The @licenseType might be related to the session type. (client, web, business connector), but not sure.

    What time is elapsing between startup of an AOS and getting the maximum client session number? Is it about hours, days, weeks? Are there clients which keeps the session open during night? I have worked with implementations where there were more than 1700 users created in the system (using 4-6 AOS servers) and they did not have this issue.

  • Francesco Profile Picture
    524 on at
    RE: AOS crashes on max session Id (65535)

    Hi André,

    Thanks. The number 65535 is actually hardcoded in the SP and I understand its origins. I don't suppose that @maxclientId refers to the same number. There is another parameter named @clienttype. I assume this one refers to the session type, although it's black box for me too.

    It takes about a week to reach the 60k, with no more than 50-100 users and a few web clients. There are inactive sessions, but not tens of thousands. I don't know if it's supposed to reuse available session ID's, but I assume so. Never had to deal with it before and as you say, bigger environments don't have this problem. Because of that I'm still contemplating how to best attack this issue.

    You might be on to something with the max number of sessions. Limit the number of active connections is checked, but there is no value in it (which I presume gives the max, which is the magic number, which might well be the @maxclients parameter).

  • André Arnaud de Calavon Profile Picture
    299,407 Super User 2025 Season 2 on at
    RE: AOS crashes on max session Id (65535)

    Hi Francesco,

    It would be possible to write a script to restart the AOS services. But, it should fit with the processes. If you have to run a lot of batch jobs, there might be a limitation in time slots.

  • Francesco Profile Picture
    524 on at
    RE: AOS crashes on max session Id (65535)

    Today I had an opportunity to monitor the normal behavior of the SYSCLIENTSESSIONS table:

    When a user opens a session, two new session ID's are written to the SYSCLIENTSESSIONS table.

    It does not place them "at the end" of the table, but it overwrites the first two inactive sessions (STATUS = 0) that it can find.

    After initiation, the second session immediately becomes inactive itself.

    The session ID's are neatly in order starting from 3 (i.e. 3, 4, 5, etc.). On the faulty system the session ID's are messy (i.e. 4, 16, 17, 32, 37, 68...).


    Ergo, an AX environment should never have more records in SYSCLIENTSESSIONS then (roughly) the historical maximum of online users.

    Now that I know what its supposed to do, I at least have some sense of direction, but I'm still very much open for good suggestions. 

  • Francesco Profile Picture
    524 on at
    RE: AOS crashes on max session Id (65535)

    So with that knowledge I found a SQLjob that deletes inactive sessions (status = 0). I already opened my bottle of bourbon. That would explain everything. If the inactive sessions are not there, they cannot be re-used and subsequently must be added, eventually resulting in a breach of the maximum memory address of 65535.

    Unfortunately peanutbutter (sounds better in Dutch), this job MIGHT have caused the problem or even WOULD cause the problem, but without the job it still increments session ID's rather than reusing inactive ones.

  • Suggested answer
    Francesco Profile Picture
    524 on at
    RE: AOS crashes on max session Id (65535)

    And for the final chapter in this one-sided discussion, it looks like the job was the problem after all, but the SYSCLIENTSESSIONS table actually needs to be in order for things to work properly. That means there should be no gaps in the session ID's or else it will increment the highest number and create a subsequent mess.

    With a quick reshuffle and reorganize the problem appears to be...fixed.

    I'll maintain a careful reservation because according to the admin the problem existed long before the job, but so far, so good. It's always the customization, isn't it?

  • André Arnaud de Calavon Profile Picture
    299,407 Super User 2025 Season 2 on at
    RE: AOS crashes on max session Id (65535)

    Hi Francesco,

    If allowed, I would like to join the discussion again... You could have mentioned "Helaas, Pindakaas" (Unfortunately peanutbutter) as I'm also Dutch.

    Can you tell which SQL-job you found? Is it a custom script? What exactly do you mean with "reshuffle and reorganize"?

  • Francesco Profile Picture
    524 on at
    RE: AOS crashes on max session Id (65535)

    Hi André,

    The script is custom and from what I understand it was an attempt to fix the problem (not to cause it).

    I reorganized the SYSCLIENTSESSIONS table, so that the gaps in session ID's were filled with inactive lines with higher ID's. (I simply overwrote the session ID in the higher line with the first non-existing session ID).

    This seemed to work wonderfully, however....there is another problem and the case is not yet closed.

    Whenever a user opens AX, I can see three client sessions opening, of which two immediately go inactive (on another system the number is two rather than three, but whatever). Now that the session id's are continuous, these three neatly fit in to the first available slots.

    Unfortunately there are three MORE (for a total of six) sessions coming in from a completely different server. THESE three sessions do not play ball and create new session ids instead of reusing existing ones.

    So for the time being, I slowed down the process but it is still building up to session id 65535.

    The originating server of the "bad sessions" runs SharePoint, a webshop and something associated with warehouse terminals. Since my account is not associated with the latter two (and opening AX creates 6 sessions for me as well), I am pointing my scope at SharePoint, but so far I am unable to best-guess what is going on here.

    What's up with these multiple sessions?

  • André Arnaud de Calavon Profile Picture
    299,407 Super User 2025 Season 2 on at
    RE: AOS crashes on max session Id (65535)

    Hi Francesco,

    Unfortunately, I don't know details of this environment. Are there ISV/partner solutions or customizations related to the webshop and warehouse terminals? Then you can probably contact the vendor(s) if they heard about similar issues.

  • Francesco Profile Picture
    524 on at
    RE: AOS crashes on max session Id (65535)

    Okay, the plot thickens...

    Today I had a chance to reboot the server and monitoring my own account I logged on and off three times.

    47085.Capture.PNG

    This clearly illustrates the problem. Opening an AX client results in 6 sessions (logon 1 only shows 5, but this is because another user already consumed one of my inactive ones by the time I took the snapshot). Two are associated with the RD (I assume this is my actual AX client). One comes from the AOS (my server side process). Then three client sessions from the SharePoint server, which incidentally also runs AX Anywhere (Handheld terminal server by André's employer) and a webshop API. I assume that SharePoint is the only one creating sessions and that these have to do with my role center. However, I have the sysadmin role center and it is completely empty.

    The three "SharePoint sessions" do not re-use available slots, but add additional records in sysclient. As can be expected they all are of client type 'server user'.

    I've done a little "debugging" by catching the SP variables in a custom table.

    As it turns out, the values for the "bad" sessions are:

    @clienttype = 5 (server session)

    @sessiontype = 0 

    @licensetype = 0

    @sessionId = -1 (if a slot is found then @max_val is inserted)

    @startId = 3

    The problem comes however from @maxClientId, a parameter being fed to the SP. This one is set to the highest session ID instead of to the highest session ID with status = 0.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans