# Error encountered when downloading file from blob

• ### Question

• Hi, I've trying to upload and download files from the blob storage. The file is 100MB.

The upload step is fine, but when I try to download it, it cannot proceed after downloading 60MB.

The error message is:

Unable to read data from the transport connection: The connection was closed.

The upload code is as following.

FileStream ustream = new FileStream(@"path\to\my\file", FileMode.Open);

ustream.Position = 0;

blob.UploadFromStream(ustream);


And the download code is:

CloudBlob download = blobContainer.GetBlobReference("myfile");
FileStream fstream = new FileStream(@"path\to\dest", FileMode.Create);
download.DownloadToStream(fstream);

The error always appears when 60MB is downloaded.

Any thought about it?

Sunday, April 24, 2011 11:16 PM

### Answers

• Can you increase the timeout? By default the timeout is set to 90s and you may need more time to download 100MB file. You can also use a tool like wireshark/netmon to see if there is a problem with network (packet retransmission/advertised window etc.). Here is a sample which uses 5 minutes to download - you can increase/decrease based on the observed network speed.

  blob.DownloadToStream(stream, new BlobRequestOptions()
{
Timeout = TimeSpan.FromMinutes(5)
});


Btw, the reason why upload would work is because the timeout applies to each request made to the service and uploading 100 MB would be done by issuing multiple 4MB block uploads (or the block size you have set) and a final commit for PutBlockList. My guess is that the default timeout would have been sufficient for each of the 4MB request.

Thanks,

Jai

• Proposed as answer by Thursday, April 28, 2011 5:30 PM
• Marked as answer by Monday, May 2, 2011 2:52 AM
Monday, April 25, 2011 4:58 AM

### All replies

• Can you increase the timeout? By default the timeout is set to 90s and you may need more time to download 100MB file. You can also use a tool like wireshark/netmon to see if there is a problem with network (packet retransmission/advertised window etc.). Here is a sample which uses 5 minutes to download - you can increase/decrease based on the observed network speed.

  blob.DownloadToStream(stream, new BlobRequestOptions()
{
Timeout = TimeSpan.FromMinutes(5)
});


Btw, the reason why upload would work is because the timeout applies to each request made to the service and uploading 100 MB would be done by issuing multiple 4MB block uploads (or the block size you have set) and a final commit for PutBlockList. My guess is that the default timeout would have been sufficient for each of the 4MB request.

Thanks,

Jai

• Proposed as answer by Thursday, April 28, 2011 5:30 PM
• Marked as answer by Monday, May 2, 2011 2:52 AM
Monday, April 25, 2011 4:58 AM
• Thanks Jai, I've found the reason, and it is due to the timeout indeed.
Wednesday, April 27, 2011 3:09 PM