3
votes

I have a wcf service which I user for transfering files. im using basicHttpBinding Streamed mode on. I configured some values in both web.config and app.config(client side) properly(I guess) but it doesn't work as I expect. It can send and receive up to 1,610,611,200 bytes which is nearly 1.5 gb. everytime i upload a file larger than this size to server, at this limit my service method throws the "An exception has been thrown when reading the stream." exception. and when i try to download a file larger than this size then it throws the "Exception of type 'System.OutOfMemoryException' was thrown." exception. Here are my config files related parts. Hope someone can give me some point to figure out this problem.

 <basicHttpBinding> (web config)
    <binding name="StreamServiceHttpBinding" receiveTimeout="01:00:10" sendTimeout="03:00:30" maxBufferPoolSize="2147483647"
      maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
      transferMode="Streamed">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding>
  </basicHttpBinding>

 <basicHttpBinding> (app config)
    <binding name="BasicHttpBinding_IStreamService" receiveTimeout="01:00:10"
      sendTimeout="03:00:30" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
      maxReceivedMessageSize="2147483647" transferMode="Streamed">
      <readerQuotas maxDepth="128" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binding> 
  </basicHttpBinding>

btw I've got 8gb of ram at server and 8gb of ram at client too. since it is streamed transferMode it doesn't necessarily use the rams but im thinking now if it's a memory problem :( any help would be appreciated.

2
you should stream it by into smaller chunks. - jerjer
here is a good article for this msdn.microsoft.com/en-us/library/ms733742.aspx - jerjer
unfortuantely I couldnt find any beneficial information to my situation in this article :/ thanks a lot though, i've learned good things reading this ;) - Tolga Evcimen
You might consider increasing the httpRuntime maxrequest length as shown : <httpRuntime maxRequestLength="2097150"/> - Rajesh
I am having the same issue. What did you end up doing? - Kyle Johnson

2 Answers

0
votes

I was suffering same issue last week. I think i found a solution. I changed maxReceivedMessageSize="4294967295" (nearly 4GB) and increased my timeouts.

app.config

<bindings>
      <basicHttpBinding>
        <binding name="GShare.Sharer" receiveTimeout="00:40:00" sendTimeout="00:40:00" maxReceivedMessageSize="4294967295" maxBufferSize="2147483647" maxBufferPoolSize="4294967295" transferMode="StreamedRequest">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <security mode="None">
          </security>
        </binding>
      </basicHttpBinding>
</bindings>

<system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="4294967295"/>
      </requestFiltering>
    </security>
  </system.webServer>

client web.config

<binding name="BasicHttpBinding_ISharer" closeTimeout="24:01:00" openTimeout="24:01:00" receiveTimeout="24:10:00" sendTimeout="24:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="4294967295" maxBufferSize="2147483647" maxReceivedMessageSize="4294967295" textEncoding="utf-8" transferMode="Streamed" useDefaultWebProxy="true" messageEncoding="Text">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
 </binding>

After that, I uploaded 1.89GB file succesfully.

0
votes

Thanks @JJ_CoderHir.

I was getting the same issue. using below code it is resolved. As per my understanding due to default value of "requestLengthDiskThreshold" properly I am was getting the System.OutOfMemory issue. So I have change it now it is working as per my expectation.

<system.web>
    <httpRuntime maxRequestLength="2147483647" requestLengthDiskThreshold="2097151" executionTimeout="240"/>
</system.web>
<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="2147483648" />
        </requestFiltering>
    </security>
</system.webServer>