Why does the MaxReceiveMessageSize in WCF matter in case of Streaming

The default value of MaxReceiveMessageSize in WCF is 65,536. When you choose streaming as TransferMode, WCF runtime will create 8192 as buffer size. So what happened now is that WCF channel stack will read the first 8192 bytes, and decode the first couple of bytes as the size of the entire envelope. Then we will do a size check, and send back fault if the actual size exceeds the limit.

According to MSDN documentation, the MaxReceiveMessageSize is something that prevents a DOS attack, and it should still apply in the streaming case to the entire message size.

https://msdn.microsoft.com/en-us/library/system.servicemodel.channels.transportbindingelement.maxreceivedmessagesize.aspx

 

The error message you sometimes get looks like something like this.

 

Unhandled Exception: System.ServiceModel.CommunicationException: The maximum message size quota for incoming messages (1) has been exceeded. To increase the quo
ta, use the MaxReceivedMessageSize property on the appropriate binding element.
---> System.ServiceModel.QuotaExceededException: The maximum message size quota for incoming messages (1) has been exceeded. To increase the quota, use the MaxR
eceivedMessageSize property on the appropriate binding element.