Blob download throws Transport connection closed exception

Yanıt Blob download throws Transport connection closed exception

  • 06 Mart 2012 Salı 01:00
     
      Kod İçerir

    I am trying to download a blob from the blob storage. The blob is about 250 MB and is being downloaded as a stream. The code is given below

     public void BlobStreamDownload(string containerName, string blobName, string FileName)
            {
                
                CloudBlobContainer container = BlobClient.GetContainerReference(containerName);
                
                CloudBlob blob = container.GetBlockBlobReference(blobName);
                //blob.DownloadToFile(FileName); <- same error
                using (Stream file = File.Create(FileName))
                {
                    blob.DownloadToStream(file); /* I am using SDK v1.6 *.
                }
            }


    The exact exception message is "Unable to read data from the transport connection: The connection was closed". Where should I look for solution? Thank you.


    Dinesh Agarwal


Tüm Yanıtlar

  • 06 Mart 2012 Salı 04:18
     
     

    Hello.

    I think that this problem can occur when:

    1) nothing is here

    2) timeout

    Do you sure that your blob exist?

  • 06 Mart 2012 Salı 04:43
     
     

    Yes, I am sure because in my app the list is populated with all the blobs that are present in the container. Also, I am able to download 2 MB files without any issue. It is only with larger files.


    Dinesh Agarwal


  • 06 Mart 2012 Salı 07:59
    Moderatör
     
     

    Hi,

    It may happened if your network connection is too slow (for example, download speed is less than 10 KB/s). If the network connection is fine, please try the download again. Please also check if your application/proxy/network has some limitations on the max response returned by a server.

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

  • 06 Mart 2012 Salı 18:16
     
     

    I agree with Ming - what download speeds are you getting?  Are you able to task manager to see this?  It'd be great to know how much of the file is downloading before you hit this error, and whether that value is consistent on each attempt.


    -Jeff

  • 07 Mart 2012 Çarşamba 06:17
     
     
    Downloading speed is not an issue for sure. The net is about 100 MB/s at school. I use the API, how do I find out how much has been downloaded?

    Dinesh Agarwal

  • 07 Mart 2012 Çarşamba 17:50
     
     Yanıt Kod İçerir

    Hi Dinesh -

    Actually, the most likely cause for this is the timeout.  By default, the download operations have a 90 second timeout.  If the blob hasn't completed downloading in that time, then this exception will be thrown.

    Create a BlobRequestOptions object like this (this one results in a 10 minute timeout - you should choose a time based on expected download rates and acceptable wait times):

    BlobRequestOptions options = new BlobRequestOptions();
    options.Timeout = new TimeSpan(0, 10, 0);

    And then pass it in to the Download method.  Hope that helps - if you increase this time, and you get the exception above in less time than the timeout specified, then there may be something else going on.

    -Jeff

    • Yanıt Olarak İşaretleyen dinwal_pdc_guy 07 Mart 2012 Çarşamba 23:10
    •  
  • 07 Mart 2012 Çarşamba 23:10
     
     
    Thank you Jeff. I will try it and let you know if I have further questions.

    Dinesh Agarwal

  • 02 Mayıs 2012 Çarşamba 10:16
     
     

    Hi I Think you should not download the BLOB as a whole.

    Try dividing the stream into diffrent chunks and then download.

    Best Regards,

    Brij Mohan