title: Increasing timeout for WCF web service in c#
body: <p>I currently have an application that is calling a web service on a server for searching. We can expect a large amount of data to be returned, so a search to take longer than a minute is routine. </p>
  
  <p>We've been receiving the below error message for such large volume searches:</p>
  
  <blockquote>
    <p>The request channel timed out while waiting for a reply after 00:00:59.7350618. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.</p>
  </blockquote>
  
  <p>This is something that we've seen asked in multiple questions already posted on StackOverflow, unfortunately none of the available solutions have helped me fix the issue or even be able to configure the time out window. </p>
  
  <p>We've both changed the app.config for the client, increased all the timeouts involved there (CloseTimeout, OpenTimeout, ReceiveTimeout, and SendTimeout) and all web.config values for the service on the server (closeTimeout, openTimeout, and SendTimeout). </p>
  
  <p>None of these changes have had any effect, I still receive the minute timeout.  Any idea why changes to these values would have no effect?</p>
  
  <p>In the examples below, we lowered the time to keep us from having to wait for the full minute during testing. </p>
  
  <p>Web.config:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.diagnostics&gt;
      &lt;trace autoflush="true" /&gt;
      &lt;sources&gt;
        &lt;source name="System.Net"&gt;
          &lt;listeners&gt;
            &lt;add name="TraceFile" /&gt;
          &lt;/listeners&gt;
        &lt;/source&gt;
        &lt;source name="System.Net.Sockets"&gt;
          &lt;listeners&gt;
            &lt;add name="TraceFile" /&gt;
          &lt;/listeners&gt;
        &lt;/source&gt;
      &lt;/sources&gt;
      &lt;sharedListeners&gt;
        &lt;add name="TraceFile" type="System.Diagnostics.TextWriterTraceListener"
             initializeData="trace.log" /&gt;
      &lt;/sharedListeners&gt;
      &lt;switches&gt;
        &lt;add name="System.Net" value="Verbose" /&gt;
        &lt;add name="System.Net.Sockets" value="Verbose" /&gt;
      &lt;/switches&gt;
    &lt;/system.diagnostics&gt;
    &lt;system.serviceModel&gt;
      &lt;diagnostics&gt;
        &lt;messageLogging logMalformedMessages="false" logMessagesAtServiceLevel="false"
                        logMessagesAtTransportLevel="false" /&gt;
      &lt;/diagnostics&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="SearchIndexServiceBehavior" name="SearchIndex.Service"&gt;
          &lt;endpoint address="" binding="basicHttpBinding" contract="ISearchIndexServices" /&gt;
          &lt;host&gt;
            &lt;timeouts closeTimeout="00:00:10" /&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding closeTimeout="00:00:10" openTimeout="00:00:15" sendTimeout="00:00:20"
                   receiveTimeout="00:00:25" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
                   maxReceivedMessageSize="2147483647"&gt;
            &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                          maxArrayLength="2147483647" maxBytesPerRead="2147483647"
                          maxNameTableCharCount="2147483647" /&gt;
          &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="SearchIndexServiceBehavior"&gt;
            &lt;serviceMetadata httpGetEnabled="false" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.transactions&gt;
      &lt;defaultSettings timeout="00:05:00" /&gt;
    &lt;/system.transactions&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>app.config</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;configSections&gt;
    &lt;/configSections&gt;
    &lt;startup&gt;
    &lt;/startup&gt;
    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="BasicHttpBinding_ISearchIndexServices" closeTimeout="00:00:10" openTimeout="00:00:15" receiveTimeout="00:10:00" sendTimeout="00:00:20" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="5242880" maxBufferPoolSize="524288" maxReceivedMessageSize="5242880" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"&gt; 
            &lt;readerQuotas maxDepth="32" maxStringContentLength="5242880"maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
            &lt;security mode="None"&gt;
              &lt;transport clientCredentialType="None" proxyCredentialType="None" realm="" /&gt;
              &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
        &lt;endpoint address="http://MyServer/SearchIndexService/SearchIndexServices.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISearchIndexServices" contract="WFC.ISearchIndexServices" name="BasicHttpBinding_ISearchIndexServices" /&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>