title: Why does my WCF service occasionally hang on ((ICommunicationObject)channel).Close()?
body: <p>I'm using the following code to create a channel from a ChannelFactory instance.  Everything is working as expected, but occasionally I'll get a 5-30 second hang on ((ICommunicationObject)channel).Close().  It doesn't happen every time Close() is called.  It happens when the factory is warm (i.e. already started) and when the factory is cold (i.e. first start).</p>
  
  <p>What could be causing this?  I'm at a loss as to where I should start looking.</p>
  
  <pre><code>var channel = _channelFactory.CreateChannel();
  try
  {
      ((ICommunicationObject)channel).Open();
      channel.UpdateEntities(serviceEndpoint, formEndpoint, departmentContextConfiguration);
      if (((ICommunicationObject)channel).State != CommunicationState.Faulted)
          ((ICommunicationObject)channel).Close();
  }
  catch
  {
      ((ICommunicationObject)channel).Abort();
      throw;
  }
  </code></pre>
  
  <p>The factory is created elsewhere using the following code:</p>
  
  <pre><code>_channelFactory = new ChannelFactory&lt;ITCPVaultService&gt;(new NetTcpBinding(SecurityMode.None), new EndpointAddress(uri.Uri))
  </code></pre>