none
Not able to upload large files.

    Question

  • I am able to upload less than 64bk small files but I am not able to upload large files from client side. I have hosted the application in my local system by console application.

    consuming the service through console client application.

    while upload large files I am getting following errors. I tried with buffered, stream and mtom but I couldn't not fix the errors. I have gone through most of the Forums and applied the config values but no progress.

    Additional information: The remote server returned an unexpected response: (413) Request Entity Too Large.

    could you please help me to fix this issue.

    windows : 8.1

    .Net 4

    data transfer : Buffered

    Clinet config

    --------------

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

        <system.serviceModel>

            <bindings>

                <basicHttpBinding>

                 

                  <binding name="BasicHttpBinding_ITransferService" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">

                    <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

                  </binding>

                </basicHttpBinding>

            </bindings>

            <client>

                <endpoint address="http://localhost:8000/" binding="basicHttpBinding"

                    bindingConfiguration="BasicHttpBinding_ITransferService" contract="ServiceReference1.ITransferService"

                    name="BasicHttpBinding_ITransferService" />

            </client>

        </system.serviceModel>

    </configuration>

    Server Config

    -------------

    <?xml version="1.0" encoding="utf-8"?>

    <configuration>

      <system.web>

        <httpRuntime maxRequestLength="2097151" useFullyQualifiedRedirectUrl="true" executionTimeout="20160" />

        <!--<httpRuntime  maxRequestLength="2000000" executionTimeout="20160" />-->

        <compilation debug="true" />

      </system.web>

     

        <system.serviceModel>

            <behaviors>

                <serviceBehaviors>

                    <behavior name="BasicHttpBinding_ITransferService">

                        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />

                        <serviceDebug includeExceptionDetailInFaults="false" />

                        <dataContractSerializer maxItemsInObjectGraph="2147483647" />

                    </behavior>

                </serviceBehaviors>

            </behaviors>

            <bindings>

                <basicHttpBinding>

                  <binding name="BasicHttpBinding_ITransferService" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">

                    <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />

                  </binding>

                </basicHttpBinding>

            </bindings>

            <services>

                <service behaviorConfiguration="BasicHttpBinding_ITransferService" name="WCFileTransferClassLibrary.TransferService">

                    <endpoint address="" binding="basicHttpBinding" bindingConfiguration=""

                        contract="WCFileTransferClassLibrary.ITransferService" />

                    <host>

                        <baseAddresses>

                            <add baseAddress="http://localhost:8000/" />

                        </baseAddresses>

                    </host>

                </service>

            </services>

        </system.serviceModel>

    </configuration>

     [DataContract]

         public class RemoteFileInfoBytes

         {

             [DataMember]

             public string FileName;

             [DataMember]

             public long Length;

             [DataMember]

             public byte[] FileByteStream;

         }

    [ServiceContract]

        public interface ITransferService

        {

            [OperationContract]

            RemoteFileInfo DownloadFile(DownloadRequest request);

            [OperationContract]

            void UploadFile(RemoteFileInfo request);

          

            [OperationContract]

            void UploadFileonly(Stream mystream);

            [OperationContract]

            void UploadFileAsByte(RemoteFileInfoBytes request);

        }

    public class TransferService : ITransferService

        {

    }

    ----

    ServiceHost host = new ServiceHost(typeof(WCFileTransferClassLibrary.TransferService));

                host.Open();

                Console.WriteLine("ClassLibrary1.MySerice :Started");

                Console.Read();

                host.Close();

    Sunday, January 12, 2014 5:00 PM

Answers

  • Hi,

    In order to increase the size of the message, you have set the following:

    <basicHttpBinding>
    
                  <binding name="BasicHttpBinding_ITransferService" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
    
                    <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    
                  </binding>
    </basicHttpBinding>
    

    It is right, but you used the following endpoint, you did not apply the binding config to the endpoint, then by default, it can only transfer the data which is less than 64kb.

     <endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
    
                        contract="WCFileTransferClassLibrary.ITransferService" />
    

    So please change your endpoint as below:

     <endpoint address="" binding="basicHttpBinding" 
    bindingConfiguration="BasicHttpBinding_ITransferService" contract="WCFileTransferClassLibrary.ITransferService" />
    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 13, 2014 6:31 AM
    Moderator

All replies

  • Hi,

    In order to increase the size of the message, you have set the following:

    <basicHttpBinding>
    
                  <binding name="BasicHttpBinding_ITransferService" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
    
                    <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    
                  </binding>
    </basicHttpBinding>
    

    It is right, but you used the following endpoint, you did not apply the binding config to the endpoint, then by default, it can only transfer the data which is less than 64kb.

     <endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
    
                        contract="WCFileTransferClassLibrary.ITransferService" />
    

    So please change your endpoint as below:

     <endpoint address="" binding="basicHttpBinding" 
    bindingConfiguration="BasicHttpBinding_ITransferService" contract="WCFileTransferClassLibrary.ITransferService" />
    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 13, 2014 6:31 AM
    Moderator
  • Thank you very much for you timely and helpful assistance.

    Tuesday, January 21, 2014 6:40 AM