I have a WCF file transfer service that is throwing QuotaExceededException
when my file is bigger than 1.5 GB. I've reviewed similar posts but I'm not understanding why I'm getting the exception or how to resolve it.
System.ServiceModel.QuotaExceededException: The maximum message size quota for incoming messages (2147483647) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.
Here's a snip of my client app.config
:
<basicHttpBinding>
<binding name="BasicHttpBinding_IFileTransfer"
maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
transferMode="Streamed"
receiveTimeout="00:30:00" sendTimeout="01:30:00"
openTimeout="00:30:00" closeTimeout="00:30:00">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="16384"/>
</binding>
</basicHttpBinding>
Here's a snip of my web.config
:
<basicHttpBinding>
<binding name="FileTransfer" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647" transferMode="Streamed"
receiveTimeout="00:30:00" sendTimeout="01:30:00"
openTimeout="00:30:00" closeTimeout="00:30:00">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="16384"/>
</binding>
</basicHttpBinding>
Here's a snip of the service code that's throwing the exception:
var sum = 0;
try
{
FileStream targetStream;
var sourceStream = request.FileByteStream;
using (targetStream = new FileStream(tfile, FileMode.Create, FileAccess.Write, FileShare.None))
{
const int bufferLen = 1024 * 64;
var buffer = new byte[bufferLen];
int count;
while ((count = sourceStream.Read(buffer, 0, bufferLen)) > 0)
{
targetStream.Write(buffer, 0, count);
sum += count;
}
targetStream.Close();
sourceStream.Close();
}
}
catch (Exception ex)
{
Logger.Debug("sum = " + sum); // sum = 1610609664 bytes (this is 1.499997 GB)
Logger.LogException(ex);
}
I can't get anything larger that 1.5 GB