title: WCF Error MTOM Encoding + sending large data from client to service
body: <p>I am trying out <a href="http://msdn.microsoft.com/en-us/library/aa395209%28VS.100%29.aspx" rel="nofollow">this example</a> from MSDN.</p>
  
  <p>I try to send a file by making use of FileStream and WCF.</p>
  
  <p>When I send small files with only a few bytes I get the output. But when I try to send across a file of a few MB I get an error:</p>
  
  <blockquote>
    <p>System.ServiceModel.CommunicationException: An error (The request was aborted: The request was cancelled).</p>
  </blockquote>
  
  <p>I have changed the max values within the binding and set it to bigger value. I have also changed the timeout. I have enabled tracing, but there is no error to be found in the trace.</p>
  
  <p>I am not able to figure out the issue. Can anyone help?</p>
  
  <p>here is the service .. config file</p>
  
  <p></p>
  
  <pre><code>&lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="wsHttpServiceBehavior"&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
        &lt;serviceMetadata httpGetEnabled="true"/&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  
  &lt;bindings&gt;
    &lt;wsHttpBinding&gt;
      &lt;binding name="customWsHttpBinding" messageEncoding="Mtom"
               openTimeout="00:10:00"  maxReceivedMessageSize="2147483647"
               closeTimeout="00:10:00"
               receiveTimeout="00:10:00"
               sendTimeout="00:10:00"&gt;
        &lt;readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxNameTableCharCount="16384"/&gt;
      &lt;/binding&gt;       
    &lt;/wsHttpBinding&gt;
  &lt;/bindings&gt;
  
  &lt;services&gt;
    &lt;service name="MTOMUploadService.UploadService" behaviorConfiguration="wsHttpServiceBehavior"&gt;
      &lt;endpoint address="mex" contract="IMetadataExchange" binding="wsHttpBinding"/&gt;
      &lt;endpoint contract="MTOMUploadService.IUploadService" binding="wsHttpBinding"  bindingConfiguration="customWsHttpBinding" /&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  </code></pre>
  
  <p></p>
  
  <p>here is the client config....</p>
  
  <pre><code>&lt;system.serviceModel&gt;
  
      &lt;bindings&gt;
          &lt;wsHttpBinding&gt;
              &lt;binding name="WSHttpBinding_IUploadService" closeTimeout="00:10:00"
                  openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                  bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
                  messageEncoding="Mtom" textEncoding="utf-8" useDefaultWebProxy="true"
                  allowCookies="false"&gt;
                  &lt;readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                  &lt;reliableSession ordered="true" inactivityTimeout="00:10:00"
                      enabled="false" /&gt;
                  &lt;security mode="Message"&gt;
                      &lt;transport clientCredentialType="Windows" proxyCredentialType="None"
                          realm="" /&gt;
                      &lt;message clientCredentialType="Windows" negotiateServiceCredential="true"
                          algorithmSuite="Default" /&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
          &lt;endpoint address="http://machinename:4575/MTOMUploadService.svc"
              binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IUploadService"
              contract="IUploadService" name="WSHttpBinding_IUploadService"&gt;
              &lt;identity&gt;
                  &lt;servicePrincipalName value="machinename" /&gt;
              &lt;/identity&gt;
          &lt;/endpoint&gt;
      &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>