CloseSession throws NullReferenceException


  • Hi,

    I am working a service running on HPC 2016 Update 1.

    From client node, I am able to submit task and task finished. But task stayed on running state. Checking the event log, I can see there is null reference exception. 

    Further investigating, I found the null reference exception is raised in CloseSession. The stack trace is:

       at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
       at Microsoft.Hpc.Scheduler.Session.V3Session.CloseSession(String headNode, Int32 sessionId, Binding binding, Boolean isAadUser)
       at Microsoft.Hpc.Scheduler.Session.Session.CloseSession(String headnode, Int32 sessionId, Boolean isAadUser)

       at user code to call CloseSession.

    The exception source is: Microsoft.Threading.Tasks.

    Microsoft.Threading.Tasks version is

    HPC SDK version 5.1.6124.

    May I get some suggestions? Thanks.

    Wednesday, October 10, 2018 7:31 PM

All replies

  • Hi,

    What binding are you used in you SOA service? Which version of .net framework you are using?


    Thursday, October 11, 2018 2:27 AM
  • <system.serviceModel>
            <binding name="myBinding"
              <security mode="Transport" />
              <readerQuotas maxStringContentLength="65536" />
            <!--binding used by broker's backend-->
            <binding name="Microsoft.Hpc.BackEndBinding" maxConnections="1000">
              <!--for non domain joined compute nodes, the security mode should be None-->
              <security mode="Transport">
                <transport clientCredentialType="Windows" protectionLevel="None"/>

    netTcpBinding is what we used for HPC 2008 and HPC 2012. BackEndBinding is what I added for HPC 2016 (I have to add them for some HPC regression).

    Our code is compiled in VS 2010. The target framework is .NET Framework4.

    Thursday, October 11, 2018 2:17 PM
  • Hi,

    We can not locally reproduce this issue. Could you add following xml to your app.config, and provide us the log produced?

    	<trace autoflush="true" useGlobalLock="false">
    			<remove name="Default" />
    			<add name="xmlt" />
    		<add name="xmlt" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "c:\TEMP\trace.svclog" />
    		<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "c:\TEMP\session.svclog" />
    		<add name="xmls" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "c:\TEMP\hpcsoa.svclog" />
    		<source name="SOA Session API" switchValue="All">
    				<remove name="Default" />
    				<add name="xml"/>
    		<source name="HpcSoa" switchValue="All">
    				<remove name="Default" />
    				<add name="xmls" />



    Friday, October 12, 2018 4:06 AM
  • Thanks Zihao.

    I figured out how to replicate this issue.

    1. Get HPC 2012 SDK batch example.

    2. Update HPC sdl with 5.1.6124 using nuget.

    3. Change the session.Close(true) to Session.CloseSession("10.xx.xx.xx", sessionId ) in ResponseRecevier

    This static call CloseSession will throw exception.

    Wednesday, October 17, 2018 3:31 PM
  • Hi,

    Thanks for the repro steps. We have identified that this is a bug in our SDK. A possible fix has been proposed. We'll inform you once the fix is available.


    Thursday, October 18, 2018 5:53 AM
  • Hi,

    A new version of HPC Pack SDK is published. Please find it at


    Friday, October 19, 2018 6:35 AM