title: When downloading from azure blob, I get "Unable to read data from the transport connection: The connection was closed."
body: <p>I'm using a SAS key to download from the Azure blob.  From the web role instance, I'm taking the blob streamed from the azure storage and then streaming it directly to the browser.  It works fine on small files, but when I try to download large files (1.7GB in this case), I get the following StorageException:</p>
  
  <pre><code>{Microsoft.WindowsAzure.Storage.StorageException: Unable to read data from the transport connection: The connection was closed. ---&gt; System.IO.IOException: Unable to read data from the transport connection: The connection was closed.
     at System.Net.ConnectStream.EndRead(IAsyncResult asyncResult)
     at Microsoft.WindowsAzure.Storage.Core.Util.StreamExtensions.WriteToSync(Stream stream, Stream toStream, Nullable`1 maxLength, Nullable`1 expiryTime, Boolean calculateMd5, Boolean syncRead, OperationContext operationContext, StreamDescriptor streamCopyState)
     at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](StorageCommandBase`1 cmd, IRetryPolicy policy, OperationContext operationContext)
     --- End of inner exception stack trace ---
     at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](StorageCommandBase`1 cmd, IRetryPolicy policy, OperationContext operationContext)
     at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.DownloadRangeToStream(Stream target, Nullable`1 offset, Nullable`1 length, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
  </code></pre>
  
  <p><strong>Here is my calling code:</strong></p>
  
  <pre><code>try
  {
      Blob = new Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob(new Uri(BlobSasUri));
  
      httpResponse.Clear();
      httpResponse.ClearHeaders();
      httpResponse.ClearContent();
      httpResponse.BufferOutput = false;
      httpResponse.ContentType = Utilities.GetMIMEType(FileName);
      string contentDisposition;
      var browser = context.HttpContext.Request.Browser.Browser;
      var version = context.HttpContext.Request.Browser.Version;
  
      if (browser == "IE" &amp;&amp; (version == "7.0" || version == "8.0" || version == "9.0"))
          contentDisposition = "attachment; filename=" + Uri.EscapeDataString(FileName);
      else if (browser == "Safari")
          contentDisposition = "attachment; filename=" + FileName;
      else
      {
          // Android Chrome browser unable to use UTF-8 encoding
          if (Regex.IsMatch(context.HttpContext.Request.UserAgent, @"Android") &amp;&amp;
              Regex.IsMatch(context.HttpContext.Request.UserAgent, @"Chrome"))
          {
              contentDisposition = "attachment; filename=" + Uri.EscapeDataString(FileName).Replace("'", Uri.HexEscape('\''));
          }
          else
          {
              // This is RFC5987 format, specifying use of utf-8. Apostrophes must be encoded for Chrome.
              contentDisposition = "attachment; filename*=UTF-8''" +
                                   Uri.EscapeDataString(FileName).Replace("'", Uri.HexEscape('\''));
          }
      }
  
      httpResponse.AddHeader("Content-Disposition", contentDisposition);
      httpResponse.AddHeader("Content-Length", eBFile.FileSize.ToString(CultureInfo.InvariantCulture));
  
      Blob.DownloadToStream(
          httpResponse.OutputStream
      );
  
      // More gracefully ends the http request
      httpApp.CompleteRequest();
  }
  catch (Exception ex)
  {
      throw ex;
  }
  </code></pre>
  
  <p>Any ideas as to what might be causing the azure library stream to quit prematurely?  My download speed is a decent 30Mbps.  Much appreciated!</p>