none
WCF service CommunicationException with a 10 mins timeout IIS7.5 hosting RRS feed

  • Question

  • Hi,
    I'm using a wcf service hosted in IIS 7.5 to call a long running method and I obtain the following error:
    <Exception><ExceptionType>System.Threading.ThreadAbortException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
    <Message>Thread was being aborted.</Message>
    <StackTrace>  
       at System.Threading.WaitHandle.WaitMultiple(WaitHandle[] waitHandles, Int32 millisecondsTimeout, Boolean exitContext, Boolean WaitAll)
       at System.Threading.WaitHandle.WaitAny(WaitHandle[] waitHandles, Int32 millisecondsTimeout, Boolean exitContext)
       at System.ServiceModel.Channels.IOThreadTimer.TimerManager.OnWaitCallback(Object state)
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke2()
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.OnSecurityContextCallback(Object o)
       at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke()
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ProcessCallbacks()
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.CompletionCallback(Object state)
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
       at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)</StackTrace><ExceptionString>System.Threading.ThreadAbortException: Thread was being aborted.
       at System.Threading.WaitHandle.WaitMultiple(WaitHandle[] waitHandles, Int32 millisecondsTimeout, Boolean exitContext, Boolean WaitAll)
       at System.Threading.WaitHandle.WaitAny(WaitHandle[] waitHandles, Int32 millisecondsTimeout, Boolean exitContext)
       at System.ServiceModel.Channels.IOThreadTimer.TimerManager.OnWaitCallback(Object state)
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke2()
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.OnSecurityContextCallback(Object o)
       at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke()
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ProcessCallbacks()
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.CompletionCallback(Object state)
       at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
       at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)</ExceptionString></Exception>
      
    The web.config of the service is the following:
    <system.serviceModel>
      <bindings>
          <wsHttpBinding>
            <binding name="WSHttpBinding_IMyService" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00">
              <reliableSession inactivityTimeout="23:00:00"/>
            </binding>
          </wsHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="MyServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <services>
          <service behaviorConfiguration="MyServiceBehavior" name="MyService">
            <endpoint bindingNamespace="mybinding" bindingName="WSHttpBinding_IMyService" address="" binding="wsHttpBinding" contract="IMyService">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
      <host>
       <timeouts closeTimeout="01:00:00"/>
      </host>
          </service>
        </services>
      </system.serviceModel>
     
      The client binding is via code:
       var binding = new WSHttpBinding
                                  {
                                      Name = "WSHttpBinding_IMyService",
                                      MessageEncoding = WSMessageEncoding.Text,
                                      TextEncoding = Encoding.UTF8,
                                      UseDefaultWebProxy = true,
                                      AllowCookies = false,
                                      BypassProxyOnLocal = false,
                                      HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
                                  };

                binding.Security.Mode = SecurityMode.Message;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                binding.Security.Transport.Realm = "";
                binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
                binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
                binding.Security.Message.NegotiateServiceCredential = true;
                binding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default;
                binding.Security.Message.EstablishSecurityContext = true;
                binding.ReceiveTimeout = TimeSpan.FromMinutes(timeout);
                binding.SendTimeout = TimeSpan.FromMinutes(timeout);
       binding.CloseTimeout = TimeSpan.FromMinutes(timeout);
                binding.OpenTimeout = TimeSpan.FromMinutes(timeout);
                binding.ReliableSession.InactivityTimeout = TimeSpan.FromMinutes(timeout);
      
     where timeout is 30000 seconds.
     
    If the server responds in less than 10 minutes all is ok, otherwise the exception described above is thrown.

    Thanks in advance, please is urgent.

    AryP

    Thursday, February 7, 2013 10:04 AM

Answers

  • Hi,

    From your configuration, you need use bindingConfiguration instead of bindingName.

    <binding name="WSHttpBinding_IMyService" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"> <reliableSession inactivityTimeout="23:00:00"/> </binding> ... <endpoint bindingNamespace="mybinding" bindingConfiguration="WSHttpBinding_IMyService" address="" binding="wsHttpBinding" contract="IMyService">


    You can find the difference bindingConfiguration and bindingName between here.

    http://msdn.microsoft.com/en-us/library/ms731320.aspx

    If the issue still exists, please enable tracing for the servie to help to digonose the actual issue.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    • Edited by Haixia_XieModerator Tuesday, February 12, 2013 1:10 PM
    • Proposed as answer by MatteoGentile Tuesday, February 12, 2013 3:52 PM
    • Marked as answer by AryP Wednesday, February 13, 2013 4:26 PM
    Tuesday, February 12, 2013 1:07 PM
    Moderator