transferMode="Streamed" ...really? RRS feed

  • Question

  • Hello,

    Env : VS 2010 / .NET 4.0

    I created a simple WCF using basicHttpBinding with  transferMode="Streamed"... It is currently hosted in IIS.

    It works OK..I could read Stream at the server side...However, the thing I am really curious is that..this is really Streamed??

    If this is real Stream mode then, isn't it supposed to be invoked the WCF method right away as soon as the Client initiate the method,(ex. Upload(Stream s) server side method) to read the stream? I don't think this is how it works...

    According to my testing, ....I tried to upload 2GB, then...once the all bytes has been transferred , and then my WCF upload method was called to process...Then what would be difference between buffered and streamed?..

    I checked the SOAP using Fiddler..too..then I noticed huge SOAP message with the serialized stream data too...

    Well...then..I don't quite understand what would be benefit of Streamed mode then...

    Am I missing something?...somehow my understanding is not correct?


    • Edited by T J Thursday, February 20, 2014 8:41 PM
    Thursday, February 20, 2014 5:15 PM


  • Hi,

    Basically, if you don't set the TransferMode to streamed, then it'll default to buffered.  In the default buffered-transfer mode, a message must be completely delivered before a receiver can read it. So if you are sending large pieces of data, it's going to build up the data on your end in memory and then send it once all the data is loaded and ready to be sent. This is why you were getting out of memory errors because the data was very large and more than your machine's memory.

    Now if you use streamed, then it'll immediately start sending chunks of data to the other endpoint instead of buffering it up, making memory usage very minimal. The streaming mode is useful when the information that is passed is lengthy and can be processed serially

    But this doesn't mean that the receiver also has to be set up for streaming. They could be setup to buffer and will experience the same problem as the sender did if they do not have sufficient memory for your data.

    For the best results, both endpoints should be setup to handle streaming (for large data files).

    Typically, for streaming, you use MessageContracts instead of DataContracts because it gives you more control over the SOAP structure.

    For more information, please try to check this article:
    #Buffered vs Streamed:
    http://blogs.msdn.com/b/drnick/archive/2006/03/31/565558.aspx .

    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, February 21, 2014 6:43 AM