Click here to Skip to main content
14,490,316 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello WCF Friends,i have a major problem.

i'm trying to download files using REST WCF, but it appears that, for example, 16MB file takes me 56 seconds, but in regular download (same source - from a website we have) - it takes 8 seconds.

In the client side, i'm reading the chunks like that:
// Initialize
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(test.FullURL);
request.Method = test.Method.ToString();
if (test.Method != TestMethod.GET)
         {
            request.ContentType = "application/json";
            using (Stream requestStream = request.GetRequestStream())
            {
               byte[] inputStringBytes = Encoding.UTF8.GetBytes(test.InputData);
               requestStream.Write(inputStringBytes, 0, inputStringBytes.Length);
            }
         }
using (var response = request.GetResponse())
            {
               using (Stream responseStream = response.GetResponseStream())
               {
                    System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();

                    char[] btArray = new char[5242880];
                    watch.Start();
                     StreamReader rdr = new StreamReader(responseStream, Encoding.UTF8);
                     
                     int idx = 0;
                     int length = 0;
                     while (!rdr.EndOfStream)
                     {
                        idx = rdr.ReadBlock(btArray, 0, 5242880);
                        //_result.actual += new string(btArray, 0, idx);
                     }
                     watch.Stop();
                     Console.WriteLine(watch.Elapsed);
                 
               }
            }


I'm using 5MB chunks, the file is 16MB as i said.


the configuration is basiclly:
<service behaviorConfiguration="httpBehavior" name="Name">
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpBindingConfig"  behaviorConfiguration="web" contract="IService" />
      </service>     
...
...
      <webHttpBinding>
        <binding name="webHttpBindingConfig" transferMode="Streamed" maxBufferSize="52428800" maxReceivedMessageSize="52428800">
          <readerQuotas maxDepth="32" maxStringContentLength="52428800" maxArrayLength="52428800" maxBytesPerRead="52428800" maxNameTableCharCount="52428800"/>
          <security mode="Transport">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
          </security>
        </binding>
      </webHttpBinding>


(i even did large numbers in all configurations to see if that helps - nothing).

Am i missing something?

Thanks.
Posted
Updated 28-Oct-13 0:24am
v3
Comments
Member 11976836 22-Oct-15 3:00am
   
wcf with https is taking more time to stream as compared to wcf with http.
please can u help me regarding this

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100