NAV 2016 OData: The Active Session does not exist. Identification fields and values... error

Slawek_GuzekSlawek_Guzek Member Posts: 1,690
Hi All,

I am having a problem with OData webservice. I have published standard Page 7702 as OData, and sometimes it works, and sometimes it doesn't

Sound strange but if I paste the URL into a browser (Chrome) I am getting this:
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <m:code/>
  <m:message xml:lang="en-US">
    The Active Session does not exist. Identification fields and values: Server Instance ID='1028',Session ID='3674'
  </m:message>
</m:error>

Each time I refresh the data the value in Session ID=.... increases by one.

Sometimes after a few refreshes I am getting the expected result:
<?xml version="1.0" encoding="utf-8"?><feed xml:base="http://ph-jendev-1.jepowerhouse.com:7048/JEC2016Upgrade01/OData/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<id>http://ph-jendev-1.jepowerhouse.com:7048/JEC2016Upgrade01/OData/Company('JEC%202009R2')/Fields</id>
<title type="text">Fields</title><updated>2016-08-02T12:20:56Z</updated>...

One or two refreshes more and again "The Active Session does not exist" error appears

The same URL In Exprorer gives randomly or HTTP400 Bad Request, or the following (the latter more often than not):
Fields
You are viewing a feed that contains frequently updated content. When you subscribe to a feed, it is added to the Common Feed List. Updated information from the feed is automatically downloaded to your computer and can be viewed in Internet Explorer and other programs. Learn more about feeds.

Generally it seems to be "more" working in Explorer than in Chrome, but in neither of them it is 'fully' working (ie gives expected field list each time.)


The background:

The NST service runs on the box, where 4 more NST services are running. I have total of 8 NST servers hosted in one box, 3 are configured but not started, 5 are running/ 1 running NST is 2015, remaining four running are 2016 CU9.

The RTC Client can connect to the questioned service each time with no fuss.

All NST servers run o the same dedicated active directory account called NAVServer. The NAVServer account has been granted WriteSPN permissions in the domain.

All NST servers run on the same ports (mmanagement 7045, client 7046, odata 7048), they are all configured to depend on Net. Tcp Port Sharing Service.

The questioned 'fussy' service has the NTLM authentication enabled

The NAVServer account does not have Windows Admin priviledges on the server or in AD domain. But adding it to the local Administrator group on the server (and restarting the NST service) does not seem to change anything.

The SMSvcHost.exe.config includes a key added in <system.serviceModel.activation><net.tcp><allowAccounts> with the SID of the NAVServer account used to run the NST servers.
<system.serviceModel.activation>
<net.tcp listenBacklog="10" maxPendingConnections="100" maxPendingAccepts="4" receiveTimeout="00:00:30" teredoEnabled="false">
<allowAccounts>
<!-- NT AUTHORITY\NETWORK SERVICE S-1-5-20 --> <-- this is the standard one-->
<add securityIdentifier="S-1-5-20" />
<!-- NAVServer account -->
<add securityIdentifier="S-1-5-21-res-of-sid-here" /> <-- this has been added by me-->

I have also made manual URL reservations for all NST servers (using NETSH HTTP ADD URLACL URL=http://+:7046/... USER="domain\NAVServer" for each exposed service/port combination)


The CustomSettings.config looks like this (some keys removed for clarity):
<appSettings>
  <add key="NetworkProtocol" value="Default" />
  <add key="EnableSqlConnectionEncryption" value="false" />
  <add key="TrustSQLServerCertificate" value="false" />
  <add key="ClientServicesPort" value="7046" />
  <add key="SOAPServicesPort" value="7047" />
  <add key="ODataServicesPort" value="7048" />
  <add key="ManagementServicesPort" value="7045" />
  <add key="ManagementServicesEnabled" value="true" />
  <add key="ClientServicesEnabled" value="True" />
  <add key="ReportPDFFontEmbedding" value="true" />
  <add key="SOAPServicesEnabled" value="True" />
  <add key="ODataServicesEnabled" value="True" />
  <add key="SOAPServicesSSLEnabled" value="false" />
  <add key="ODataServicesSSLEnabled" value="false" />
  <add key="PublicODataBaseUrl" value="" />
  <add key="PublicSOAPBaseUrl" value="" />
  <add key="PublicWebBaseUrl" value="" />
  <add key="PublicWinBaseUrl" value="" />
  <add key="DefaultClient" value="Windows" />
  <add key="ServicesOptionFormat" value="OptionCaption" />
  <add key="ServicesLanguage" value="en-US" />
  <add key="SOAPServicesMaxMsgSize" value="1024" />
  <add key="ServicesUseNTLMAuthentication" value="True" />
  <add key="ODataServicesMaxPageSize" value="1000" />
  <add key="ClientServicesOperationTimeout" value="MaxValue" />
  <add key="ClientServicesProtectionLevel" value="EncryptAndSign" />
  <add key="MaxConcurrentCalls" value="40" />
  <add key="ClientServicesMaxConcurrentConnections" value="150" />
  <add key="ClientServicesReconnectPeriod" value="00:10:00" />
  <add key="ClientServicesMaxNumberOfOrphanedConnections" value="20" />
  <add key="ClientServicesCompressionThreshold" value="64" />
  <add key="MetadataProviderCacheSize" value="150" />
  <add key="ClientServicesMaxUploadSize" value="30" />
  <add key="EnableDebugging" value="false" />
  <add key="DebuggingAllowed" value="true" />
  <add key="ClientServicesMaxItemsInObjectGraph" value="512" />
  <add key="ClientServicesChunkSize" value="28" />
  <add key="ClientServicesCredentialType" value="Windows" />
  <add key="ClientServicesTokenSigningKey" value="" />
  <add key="ClientServicesFederationMetadataLocation" value="" />
  <add key="AppIdUri" value="" />
  <add key="ServicesCertificateThumbprint" value="" />
  <add key="ServicesCertificateValidationEnabled" value="true" />
  <add key="EnableSoftwareQualityMetrics" value="false" />
  <add key="DataCacheSize" value="9" />
  <add key="SessionEventTableRetainPeriod" value="3" />
  <add key="SqlCommandTimeout" value="00:30:00" />
  <add key="BufferedInsertEnabled" value="true" />
  <add key="DisableSmartSql" value="false" />
  <add key="DocumentServicesProvider" value="SHAREPOINTONLINE" />
  <add key="EnableFullALFunctionTracing" value="false" />
  <add key="Multitenant" value="false" />
  <add key="CloseInactiveSqlConnectionsGeneration" value="10" />
  <add key="EnableALServerFileAccess" value="true" />
  <add key="EncryptionProvider" value="LocalKeyFile" />
  <add key="ClientServicesIdleClientTimeout" value="MaxValue" />
  <add key="Binding" value="" />
  <add key="UseQueryForFind" value="False" />
  <add key="SqlParametersByOrdinal" value="True" />
  <add key="SessionEventTablePurgeLookupPeriod" value="24:00:00" />
  <add key="ResultSetGroupCacheUsesGlobalCache" value="True" />
  <add key="UseCalculatedFieldsCache" value="True" />
  <add key="UseResultSetCache" value="True" />
  <add key="EnableTempTableSizeReporting" value="False" />
  <add key="ClientBuildRestriction" value="AlwaysConnect" />
  <add key="DisableDataCache" value="False" />
  <add key="WildcardEvaluationTimeout" value="0:00:05" />
  <add key="EnableODataStrictFiltering" value="True" />
  <add key="TraceLevel" value="Normal" />

</appSettings>


I am really stuck at this point.

What else could I check or configure? Where to search for potential error logs?

Kind regards,
Slawek
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03

Answers

  • JuhlJuhl Member Posts: 724
    Try without portsharing, or stop all services but one, that servs odata.
    Follow me on my blog juhl.blog
  • archer89archer89 Member Posts: 337
    try to increase the ClientServicesChunkSize.
    best regards
    Franz Kalchmair, MVP
    Alias: Jonathan Archer

    please like / agree / verify my answer, if it was helpful for you. thx.
    Blog: http://moxie4nav.wordpress.com/
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Juhl wrote: »
    Try without portsharing, or stop all services but one, that servs odata.

    Hi Juhl,

    I tried stopping all NSTs but one and it didn't help. I have also tried to remove dependency on port sharing service, restarted the NST but it made no difference. Tried to change service type to own, restarted the NST and still no improvement


    I have noticed that it never works righ after restarting the NST - always getting The Acticve Session does not exist... error with Session ID=3 (sessions numbering restarts after restarign NST, for some reason the first one reported in error is always 3)

    If I refresh the page quickly it also doesn't work and each refresh returns The Acticve Session does not exist... error

    But when I refrehs the page a few seconds after getting the error it usually works. Then again if I try to refresh shortly after getting correct results it fails agan. But If I wait another few seconds it works more often than not.


    I have monitored Active Session table through SQL Sever Managamant Studion and I have found that:

    1. Session IDs in Active Session table are negative

    2. Righ after NST restart there is an old entry left in Active Session table with the Session ID of last successfull connection

    3. On attempt of connection from Chrome the old entry in Active Session table gets removed, and new one is inserted. Interesting observartion is that Chrome reports the The Active Session does not exists... error with an Session ID which is different to what has been inserted in the Active Session table (so the error says "The Active Session does not exist. Identification fields and values: Server Instance ID='1035',Session ID='4'" and I can see a new entry inserted in Active Session table with Session ID=-3

    4. If I manually clear Active Session table through the SQL (issue DELETE [Active Session]) the next connection attempt works OK. Always.

    5. When I refresh the page same happens - immediate refresh results in The Active Session does not exist.... error. 'Slow' refresh results works OK

    6. Each quick refresh results in The Active Session does not exist.... error displayed in Chrome with next number in Session ID. However the Active Session table still has an enrty with the Session ID of last successfull connection attempt.

    7. "Slow" (or delayed by few secs) refresh results in successfull connection and a new entry in the Active Session table

    8. Deleting the entries in Active Session table in SQL does not break numbering - new entries are created with ever increasing (or more precisaly decreasing) Session ID until the NST is restareted.

    9. Each time a connection is successfull and expected result are shown in Chrome a new entry in Active Session table is created (it gets new Session ID and also new Session Unique ID GUID and new Login Datetime

    This is a bit puzzling as it looks like the NST tries to reuse the old session (keeps an entry in the Active Session table) but new connections always wants a new Session ID so if there is nothing in the Active Session table NST creates new entry,

    If the Active Session table is not empty NST tries to match Session ID of new request with something already remembered in the Active Session table?

    All and all it looks like some NST bug to me - unless there are settings which govern connection caching which can be adjusted ?

    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    archer89 wrote: »
    try to increase the ClientServicesChunkSize.

    Hi Jonathan,

    Tried with ClientServicesChunkSize=50, it didn't make any difference

    Regards,
    Slawek
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • vaprogvaprog Member Posts: 1,140
    From my observations with SOAP web services I think, NAV creates some kind of supervisor session with the negative session ID. From this, the actual session that processes the request is spawned. The processing session is terminated as soon as the processing is finished. The supervising session with the negative ID persists for some time longer and is reused for subsequent calls.

    Concerning the actual error message: do you have any custom code in that page that accesses SESSIONID or any session related system table? If yes, revise that code. If you need the debugger, you need to debug the "next session", then call the web service.

    I think the issue is rater a bad build than a configuration issue. First, try to delete Object Metadata, then recompile the objects. If this does not help, try a different NAV platform build.
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Hi vaprog,

    No, I don't have any custom code on the page, or any variable defined. I am standard Page 7702, which doesn't even have a single line of standard (MS) code.

    I am also starting to think that the problem might be a specific build issue. We have been using it with CU3 and it worked fine, then updated to CU9 (the latest version at the time), and problems have begun.

    Tried deleting Object Metadata for Page 7702 but it didn't help. I have also tried to delete everything from the Object Metadata but it didn't help either, moreover it got me into problems with NAV client not starting, complaining about missing metadata for system tables (2000000041, 2000000045) - those which are not visible in Object Designer and hence could not be recompiled.

    By the way - how can I recompile all the objects, including system tables invisible in Object Designer?

    I've got around the problem by inserting missing Object Metadata rows another copy restored from backup, but surely there must be a way to rebuild Object Metadata table without restoring to writing SQL queries.

    I'll give it another go with CU10 and eventually raise this with Microsoft if problem persists.


    Regards,
    Slawek

    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.