Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

.NET Business Connector Session Terminated

(0) ShareShare
ReportReport
Posted on by 315
I have an application that is reading AOT information from the AOS using the .NET Business Connector. At a client site, there is a problem is that the application will get an error that the “Server has terminated the session”.
  • It is intermittent. Sometimes the application will run successfully, and the call that the error ocurs changes.
  • They say that the AX application isn’t experiencing any disconnection issues, just my application
  • The AOS Server has the following error at the time of disconnection (no errors before this):
    Object Server 01: RPC error: Client provided an invalid session ID
     
  • The event log from the machine running the .NET Business Connect & application
    • Microsoft Dynamics Business Connector Session 26., RPC exception 3758096384 occurred in session 26
    •  My Application: The server terminated the session 
  • They are running Windows Server 2003 SP2 with AX 4.0.2163.0
  • The last call from the ax trace profile is ServerUtilLoad. I am not 100% sure I am looking at the correct session, but there are not obvious connection errors recorded.

Thanks in advance,

Mark

*This post is locked for comments

  • Gonzalo García Profile Picture
    Gonzalo García 20 on at
    RE: .NET Business Connector Session Terminated

    Yes, LogonAs requires a proxy account setup in Active Directory and in AX. We are facing the same problem you were experiencing only that we are using LogonAs, the connection interruption is intermittent and the error pattern in the event viewer is exactly the same, I guess LogonAs uses impersonation at some point. Thanks for your time and help!

  • Mark Ledwich Profile Picture
    Mark Ledwich 315 on at
    RE: .NET Business Connector Session Terminated

    We were actually using .NET impersonation just for the time we opened the connection (then reverted). Similar to what this article talks about www.codeproject.com/.../A-complete-Impersonation-Demo-in-C-NET

    We now create a separate process for using the .NET BC as another user. Its a difficult thing to do if you need to communicate with that other process. The main reason we did that was to work around the problem where you can't connect to different AOT's more than once (something most of our users were trying to do).

    I can't remember why we weren't using the LogOnAs method. I believe it required a proxy account in ax to be set up?

  • Gonzalo García Profile Picture
    Gonzalo García 20 on at
    RE: .NET Business Connector Session Terminated

    Hi Mark,

    I am curious about two aspects of your solution:

    1. You stopped using impersonation, I assume this means that you started using Axapta.Logon() instead of using Axapta.LogonAs(), correct?

    2. Also, you mentioned that previously you were using impersonation when initiating the connection to AX then reverting it, how do you revert impersonation when logging in to AX using the BC API?

    best regards,

    Gonzalo Garcia

  • Raju Ilango Profile Picture
    Raju Ilango 50 on at
    Re: Re: .NET Business Connector Session Terminated

    We faced the similar issue in AX 2009 (ax 5.0). Restarting the SQL services fixed the issue but would like to understand the core cause for the same. Any relevant guidance would help. Thank you.

  • Verified answer
    Mark Ledwich Profile Picture
    Mark Ledwich 315 on at
    Re: Re: .NET Business Connector Session Terminated

    I found the solution to my particular problem. I doubt it applies to you tho Klaas, there are probably much more common causes of this error.

    I was using imersonation when initiating the connection to AX, then reverting it. This is a common partern that works for SQL. Using AX4, this seems to intermittently fail with the “Server has terminated the session” error (AX5 is fine). I stopped using impersonation and it has been working without any issues.

  • Klaas Deforche Profile Picture
    Klaas Deforche 2,431 on at
    Re: Re: .NET Business Connector Session Terminated

    Hi Ax2009Tech,

    You were right, that RPC error is of no use, the key was that the session was lost.
    I can reproduce the error:
    - I start my .NET windows service that uses the BC.NET
    - go to AX - Adminstration - Online users
    - terminate the BC.NET user sessions
    - execute an action that triggerd my service to use the BC.NET

    What I then did, is add a try/catch to my service, and a loop so I could reconnect to AX with the BC in case the error occurred.

     Like this:

    public void DoSmth()
    {
        int retryCount = 1;
        while (retryCount >= 0)
        {
            try
            {
                object o = axapta.CallStaticClassMethod("DAXClass", "DAXMethod", "parameter");
                break;
            }
            catch (Exception ex)
            {
                if (retryCount < 0)
                {
                    logger.Error(ex.Message);
                }
                else
                {
                    logger.Debug(
    "Retry. Recreating connector instance");
                    axapta = new Axapta();
                    this.Login();
                    retryCount--;
                }
            }
        }
    }

    The login method looks like this (logger is log4net object):

    private void Login()
    {
        try
        {
            axapta.Logon(
    null, null, null, null);
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }

    I'm no .NET expert, but that code worked for me.

    Thx for the assistance,
    I hope this helps others too.

    Best regards,
    Klaas.

  • Back2Ax Profile Picture
    Back2Ax on at
    Re: .NET Business Connector Session Terminated

    Hi,

     From my experience, the key here is "Object Server 01: RPC error: Client provided an invalid session ID". This message is logged when the server has closed the session (session timed out or AOS instance restarted). The RPC error is of no use (unknown RPC error). Based on this, you should check if the AOS instance was restarted between after the BC session was initiated or if a time out has occured on the session. Also remember that the .NET BC is a multi session client.

     No complete answer, but at least some tips for further investigations.

  • Klaas Deforche Profile Picture
    Klaas Deforche 2,431 on at
    Re: .NET Business Connector Session Terminated

    Hi Mark,

     I have the same problem.

    In the event viewer the following message is logged:
    - RPC exception 3758096384
    followed by
    - The server terminated the session

    Did you find the cause and a solution?
    Please share, thanks.

    Best regards,
    Klaas Deforche

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans