title: WCF Client ignores timeout values when service down
body: <p>I have a VB .NET application that uses WCF. I've set the client timeouts for everything in code:</p>
  
  <pre><code>    Dim oMastSrv As MastSvc.IclsIOXferClient = Nothing
  
      Dim binding As New ServiceModel.NetTcpBinding("NetTcpBinding_IclsIOXfer")
      Dim intTimeout As Integer = 2500
      binding.SendTimeout = New TimeSpan(0, 0, 0, 0, intTimeout)
      binding.ReceiveTimeout = New TimeSpan(0, 0, 0, 0, intTimeout)
      binding.OpenTimeout = New TimeSpan(0, 0, 0, 0, intTimeout)
      binding.CloseTimeout = New TimeSpan(0, 0, 0, 0, intTimeout)
      Dim address As New ServiceModel.EndpointAddress("net.tcp://" &amp; GetSrvIP(intSrvID) &amp; ":30000/MyMastSvc")
  
      oMastSrv = New MastSvc.IclsIOXferClient(binding, address)
      Try
          oMastSrv.ServiceConnect( ... )
          oMastSrv.InnerChannel.OperationTimeout = New TimeSpan(0, 0, 0, 0, intTimeout)
      Catch ex As Exception
          ...
      End Try
  </code></pre>
  
  <p>When the service I'm connected to crashes, though, the Endpoint Not Found exception takes over twenty seconds to be thrown, not the 2.5 I have specified. This is really mucking with my load balancing, I need to know that service is gone within 2.5 seconds. Is there any way to get this exception thrown within the desired time span?</p>
  
  <p>BTW, the exception reads something like:</p>
  
  <blockquote>
    <p>Could not connect to net.tcp://192.168.227.130:30000/MXIOXfer. The
    connection attempt lasted for a time span of 00:00:02.4209684. TCP
    error code 10060: A connection attempt failed because the connected
    party did not properly respond after a period of time, or established
    connection failed because connected host has failed to respond
    192.168.227.130:30000.</p>
  </blockquote>
  
  <p>but it really does take over twenty seconds. I've turned WCF tracing on and can see the TCP operation failed warning just before the exception and it has the REAL time:</p>
  
  <blockquote>
    <p>Could not connect to net.tcp://192.168.227.130:30000/MXIOXfer. The
    connection attempt lasted for a time span of 00:00:21.0314092. TCP
    error code 10060: A connection attempt failed because the connected
    party did not properly respond after a period of time, or established
    connection failed because connected host has failed to respond
    192.168.227.130:30000.</p>
  </blockquote>
  
  <p>If it makes any difference, all the comms to the service are done on separate threads.</p>
  
  <p>EDIT:</p>
  
  <p><a href="http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/5f347965-13bf-4a2d-ae82-74ad38a8d7d1/" rel="nofollow">This thread</a> seems to indicate that the socket timeouts are set by the operating system. Is there a registry setting for such things?</p>