Answered IIS 7 and chunk/stream file upload

  • Tuesday, February 12, 2013 6:12 PM
     
     

    I'm trying to upload a audio file through the WCF Rest services. We have a web player who can send the data to server by chunk while recording. We have to upload the large file so have choosen the CHUNKED option here. The service's method working fine, when STOP the recording or defined recording duration is over, recoreded file saved in file system.

    However, I've noticed when CHUNKED is enabled then method does not get called until the file is completely uploaded meaning its seems like WCF is caching the file somewhere before it calls the method. Instead of this behavior service method should called immediately after receving the first chunk and file should be created in the file system. We also examined the result using wireshark and found that many packets of chunk data are there but file saved only after the STOP.

    Below is the service configuartion:

    <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <standardEndpoints >
    <webHttpEndpoint >
    <standardEndpoint
    maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
    name="" helpEnabled="true" automaticFormatSelectionEnabled="true" transferMode="Streamed"/>
    </webHttpEndpoint>
    </standardEndpoints>
    </system.serviceModel>

    We also used
    appcmd set config /section:asp /enableChunkedEncoding:True|False to enable or disable HTTP 1.1 chunked transfer encoding, but it did not work.

All Replies

  • Wednesday, February 13, 2013 2:12 AM
     
     

    Be aware that by default HTTP 1.1 use by default the chunked tranfer encoding.

    When the application receive chunked's data, the packet is just the HTML's header with the transfer-type chunked, the chunked's size and a trailling 0 set at the end.

    So yes, if the file is encoded by some codec, the application surelly wait to get it all because it's multisource. So it's like a batch of small files that are getting put together. So in that way, I understand why the application wait to get the whole file before playing it.

    In non-chunked HTTP, the whole file is in the file, so how it deal it is another story (stream to a file)

    I would post that question on WCF's forum (http://social.msdn.microsoft.com/Forums/en-US/wcf/threads) to see if it's a API flaw or in IIS's forum (iis.net)  in case it's a know issue with a workaround. As you surelly can enable somewhere to stream to a file and not into memory.


    MCP | MCTS 70-236: Exchange Server 2007, Configuring

    Twitter - @yagmoth555 ()
    Blog: http://www.jabea.net | http://blogs.technet.com/b/wikininjas/

  • Wednesday, February 13, 2013 6:08 AM
     
     

    Thanks for response!

    I just want to mention one point here its working fine with Node.Js. We are able to get the required behaviour i.e file has been stored in file system on chunk data basis. So, I think  WCF service method working fine but IIS 7. 

  • Friday, February 15, 2013 2:55 AM
     
     Answered

    Hi sk1sinha, The use of chunked's method is a global standard. If IIS would not send it correctly, at the end of the send the file would be corrupted. The service/app that receive the data got the choice of what to do with the packet. Most C/C++ exemple that use winsock will re-construct the data in memory and make a CRC's check on it before saving it, so how the application handle that is another story.

    To find if IIS is the trouble, just open a wireshark on the machine receiving the streaming, you will see the Chunked attribute in all packet. If you see multiple http packet, then the chunk'ed data is beiing send in chunked encoding correctly. (So the application does not handle it correctly)

    Thanks


    MCP | MCTS 70-236: Exchange Server 2007, Configuring

    Twitter - @yagmoth555 ()
    Blog: http://www.jabea.net | http://blogs.technet.com/b/wikininjas/