none
Encoded chunk data and file upload issue RRS feed

  • Question


  • I'm trying to upload a audio file through the WCF Rest services. We have a web player who can send the data (encoded by some codec) to server by chunk while recording. We have to upload the large file so have chosen 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.                                                                                                                                                                                                                                 Note: This code working fine with Node.js but IIS 7.
    Wednesday, February 13, 2013 6:21 AM

All replies

  • Issue
    =======
    1. Trying to upload a audio file through the WCF Rest services.
    2. We have to upload the large file so have chosen the CHUNKED option here.
    3. 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.
    4. Instead of this behavior service method should called immediately after receving the first chunk and file should be created in the file system.


    Expectation
    ============
    1. In WCF Chunking message format, why does the method execution start after receiving all the chunks ? It should start on reception of first chunk itself....

    Is this is what you are looking for ?

    This looks to be an expected behavior, where we need to add all the chunks to process the message.

    http://msdn.microsoft.com/en-us/library/aa717050.aspx

    On the receive side, ChunkingChannel pulls messages from the inner channel and hands them to a custom XmlDictionaryReader called ChunkingReader, which reconstitutes the original message from the incoming chunks. ChunkingChannel wraps this ChunkingReader in a custom Message implementation called ChunkingMessage and returns this message to the layer above. This combination of ChunkingReader and ChunkingMessage allows us to de-chunk the original message body as it is being read by the layer above instead of having to buffer the entire original message body. ChunkingReader has a queue where it buffers incoming chunks up to a maximum configurable number of buffered chunks. When this maximum limit is reached, the reader waits for messages to be drained from the queue by the layer above (that is, by just reading from the original message body) or until the maximum receive timeout is reached.

    Let me know for any queries.

    Thursday, February 14, 2013 5:26 PM