Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
C#
// 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:
XML
<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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900