WCF Streaming and maxReceivedMessageSize
Asked Answered
C

1

10

Why is the maxReceivedMessageSize property relevant when implementing WCF Streaming? Since buffering and persistence is handled by the consumer of the stream, why does WCF concern itself with how big or long a single service operation could take?

I'm working on a project which could handle large files from server to client and back. I figured WCF streaming is an excellent choice as it SHOULD allow for theoretically infinite file sizes to be handled. Both my client and server have transportMode (on the binding) set to "Streamed" and messages designed to contain Streams. This is not enough, however, as I get a CommunicationException indicating I need to increase the maxReceivedMessageSize property. Following the exception's advice, increasing the property magically allows everything to work perfectly.

I'm concerned that WCF is forcing me to "cap" how much my service/client can handle even though streaming is supposed to be "infinite." If a file comes along that happens to be bigger than my binding's config, the same CommunicationException will occur. I don't see why WCF is arbitrarily limiting my capacity to handle large files, "when" and "how" I send and store these files is now "my" business because I have a stream to consume however I wish.

Am I missing something?

Contrabandist answered 29/10, 2012 at 18:17 Comment(3)
see #8469551Sweep
good question and I agree it does not make sense to have a cap on streaming however there must be a one-size-fits-all check on the received message in the WCF code - you can 'bypass' this by setting maxReceivedMessageSize to Int64.MaxValue which is a limit you're not going to hit (or you could recreate the connection)Sweep
According to Gabobcat, the official reason is security/DoS attacks, but that doesn't make sense to me. One would think they could come up with a better mechanism to avoid such things, or just not address it at all (since there doesn't seem to be a great solution to DoS attacks in general.)Contrabandist
B
8

According to the documentation (at least what I've found), the reason you are "forced" to limit the size of your message is security, mostly to avoid DoS attacks, by sending too large messages and flooding the system.

As a defense mechanism, maxReceivedMessageSize places a cap on the maximum allowable size of messages on receive. The default maxReceivedMessageSize is 64 KB, which is usually too low for streaming scenarios. Source

The max size for maxReceivedMessageSize is 9,223,372,036,854,775,807 bytes.

Hope this helps.

Bidentate answered 5/11, 2012 at 21:26 Comment(1)
The answer doesn't make sense, however it is the official response from Microsoft, so thanks!Contrabandist

© 2022 - 2024 — McMap. All rights reserved.