title: WCF ServiceHost close operation timedout
body: <p>I have this huge timeout problem, i have no idea how to fix it !
  I am using a windows service client to connected to a WCF service via <strong>HTTPS</strong></p>
  
  <p>i've looked at this:
  <a href="http://blogs.msdn.com/b/hongmeig/archive/2010/03/06/timeouts-in-wcf-and-their-default-values.aspx" rel="nofollow">http://blogs.msdn.com/b/hongmeig/archive/2010/03/06/timeouts-in-wcf-and-their-default-values.aspx</a></p>
  
  <p>Error generated on the server side </p>
  
  <blockquote>
    <p>The ServiceHost close operation timed out after 00:00:10.  This could
    be because a client failed to close a sessionful channel within the
    required time.  The time allotted to this operation may have been a
    portion of a longer timeout.</p>
  </blockquote>
  
  <p>Error generated on the Client side:</p>
  
  <pre><code>System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.
  
  Server stack trace: 
     at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
     at System.ServiceModel.Channels.ServiceChannel.System.IDisposable.Dispose()
  </code></pre>
  
  <p>this is my binding  on the WCF Service:</p>
  
  <pre><code>  &lt;bindings&gt;
      &lt;wsHttpBinding&gt;
        &lt;binding name="Binding1" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"&gt;
          &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true" /&gt;
          &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" /&gt;
          &lt;security mode="TransportWithMessageCredential"&gt;
            &lt;message clientCredentialType="UserName" /&gt;
          &lt;/security&gt;
        &lt;/binding&gt;
      &lt;/wsHttpBinding&gt;
    &lt;/bindings&gt;
  </code></pre>
  
  <p>this is code client side:</p>
  
  <pre><code>        wsHttpBinding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential)
         {
             CloseTimeout = new TimeSpan(0, 0, 10, 0),
             OpenTimeout = new TimeSpan(0, 0, 10, 0),
             ReceiveTimeout = new TimeSpan(0, 10, 0, 0),
             SendTimeout = new TimeSpan(0, 0, 10, 0),
             TransactionFlow = false,
             MaxBufferPoolSize = 524288,
             MaxReceivedMessageSize = 2147483647,
             ReaderQuotas =
             {
                 MaxDepth = 128,
                 MaxStringContentLength = int.MaxValue,
                 MaxArrayLength = 2147483647,
                 MaxBytesPerRead = 16384,
                 MaxNameTableCharCount = 16384
             }
         };
  
          wsHttpBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
  
          wsHttpBinding.ReliableSession.Ordered = true;
          wsHttpBinding.ReliableSession.InactivityTimeout = new TimeSpan(0, 0, 10, 0);
          wsHttpBinding.ReliableSession.Enabled = true;
          Ednpoint = new EndpointAddress(new Uri(URL));
  
          myChannelFactory = new ChannelFactory&lt;IPoint&gt;(wsHttpBinding, Ednpoint);
          myChannelFactory.Endpoint.Contract.SessionMode = SessionMode.Allowed;
  
          ClientCredentials cc = myChannelFactory.Endpoint.Behaviors.Find&lt;ClientCredentials&gt;();
  
          cc.UserName.UserName = usr;
          cc.UserName.Password = pass;
          myChannelFactory.CreateChannel();
  </code></pre>
  
  <p>I am using this code to send data like this:</p>
  
  <pre><code>            using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel())
              {
                  client.OperationTimeout = TimeSpan.FromMinutes(10);
                  IPoint wcfClient1 = (IPoint)client;
                  for (int start = startpos; start &lt; totalSize; start += size)
                  {
                      List&lt;Point&gt; send = r.Skip(start).Take(size).ToList();
                      xreturn = wcfClient1.Update(send);
                      counter += 1;
                  }
              }
  </code></pre>