title: Buffer size in WCF service
body: <p>We have a WCF service which executes certain stored procedures and returns the results to the silverlight client. Some of the stored procedures return upto 80K rows. </p>
  
  <p>Given below are the settings in web.config for Service</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt;
      &lt;behaviors&gt;
         &lt;serviceBehaviors&gt;
             &lt;behavior name="MyService.MyServiceBehavior"&gt;
                 &lt;serviceMetadata httpGetEnabled="true"/&gt;
                 &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
                 &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
             &lt;/behavior&gt;
         &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;bindings&gt;
         &lt;basicHttpBinding&gt;
             &lt;binding name="BasicHttpBinding_MyService" 
                  maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" 
                  receiveTimeout="00:40:00" openTimeout="00:40:00" 
                  closeTimeout="00:40:00" sendTimeout="00:40:00"&gt;
                  &lt;readerQuotas maxDepth="2147483647" 
                      maxStringContentLength="2147483647" maxArrayLength="2147483647" 
                      maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/&gt;
                  &lt;security mode="None"/&gt;
             &lt;/binding&gt;
          &lt;/basicHttpBinding&gt;
          &lt;customBinding&gt;
             &lt;binding name="MyService.MyService.customBinding0"&gt;
                &lt;binaryMessageEncoding/&gt;
                &lt;httpTransport/&gt;
              &lt;/binding&gt;
          &lt;/customBinding&gt;
       &lt;/bindings&gt;
       &lt;services&gt;
            &lt;service behaviorConfiguration="MyService.MyServiceBehavior" 
                     name="MyService.MyService"&gt;
                &lt;endpoint name="BasicHttpBinding_MyService" 
                    address="" 
                    binding="basicHttpBinding" 
                    bindingConfiguration="BasicHttpBinding_MyService" 
                    contract="MyService.IMyService"/&gt;
             &lt;/service&gt;
       &lt;/services&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>And this for Client</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt; 
      &lt;behaviors&gt;
         &lt;serviceBehaviors&gt;
             &lt;behavior name="MyService_Behavior"&gt;
                &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
                &lt;serviceMetadata httpGetEnabled="true"/&gt;
             &lt;/behavior&gt;
         &lt;/serviceBehaviors&gt;
         &lt;endpointBehaviors&gt;
            &lt;behavior name="r1"&gt;
                &lt;dataContractSerializer maxItemsInObjectGraph="2147483647"/&gt;
            &lt;/behavior&gt;
         &lt;/endpointBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;bindings&gt;
         &lt;basicHttpBinding&gt;
              &lt;binding name="BasicHttpBinding_MyService" 
                  closeTimeout="00:03:00" openTimeout="00:03:00" 
                  receiveTimeout="00:10:00" sendTimeout="00:03:00" 
                  allowCookies="false" bypassProxyOnLocal="false" 
                  hostNameComparisonMode="StrongWildcard" 
                  maxBufferSize="2147483647" maxBufferPoolSize="2147483647" 
                  maxReceivedMessageSize="2147483647" 
                  messageEncoding="Text" textEncoding="utf-8" 
                  transferMode="Buffered" useDefaultWebProxy="true"&gt;
                 &lt;security mode="None"/&gt;
               &lt;/binding&gt;
          &lt;/basicHttpBinding&gt;
       &lt;/bindings&gt;
       &lt;client&gt;
          &lt;endpoint name="BasicHttpBinding_MyService"
              address="http://localhost:8080/MyService/MyService.svc" 
              behaviorConfiguration="r1"
              binding="basicHttpBinding" 
              bindingConfiguration="BasicHttpBinding_MyService" 
              contract="MyService.IMyService"  /&gt;
      &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Whenever the number of records go beyond 20K, the service throws an error as either TimeOut or NotFound. Why do you think this happens n how do I fix it?</p>