question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot download blob data after upgrading to .net core 2.1 RTM (2.1.300)

See original GitHub issue

CloudBlockBlob DownloadTextAsync (WindowsAzure.Storage 9.2.0) no longer connects and downloads the blob contents after upgrading to .NET Core 2.1

The same code works when running under using .NET Core 2.0 and .NET Core 2.1 RC1

Could this issue be linked to the changes that have been made to HttpClientHandler? Note: I am making the requests on a machine that is behind a ZScalar corporate firewall and proxy server.

I have Wireshark traces and can see that using 2.1 RTM it first does a DNS lookup and then tries to connect directly using TCP to XXX.store.core.windows.net on port 443, the request does not go through the proxy server and the connection is not established. Using a previous version on .NET Core it successfully connects using HTTP via the proxy server.

Here’s the code:

string storageConnectionString = "[SecretDetailsRemoved];EndpointSuffix=core.windows.net";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
string blobName = "myblob";
string container = "mycontainer";
Uri uri = new Uri($"{storageAccount.BlobEndpoint}{container}/{blobName}");
CloudBlockBlob blob = new CloudBlockBlob(uri, storageAccount.Credentials);
string content = await blob.DownloadTextAsync();

Here’s the exception:

Microsoft.WindowsAzure.Storage.StorageException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
grahamjestcommented, Jun 7, 2018

Thanks for the suggestion. All web requests fail.

For example, this code gives the same error:

   using (HttpClient client = new HttpClient())
   {
      string content = await client.GetStringAsync("http://www.microsoft.com");
   }

I am running in a windows environment and would expect the proxy settings to default to the IE settings.

As a workaround I have found that my code works if I opt out of using the new sockets implementation using the following command:

AppContext.SetSwitch("System.Net.Http.UseSocketsHttpHandler", false);

For information on this command see: https://docs.microsoft.com/en-us/dotnet/core/whats-new/dotnet-core-2-1#api-changes and scroll to Sockets improvements

It is not ideal though to have to use the old implementation as the new library promises performance improvements!

1reaction
alexmgcommented, Sep 3, 2018

It would be great if an IWebProxy implementation could be provided when creating the clients. The EventProcessorHost in https://github.com/Azure/azure-event-hubs-dotnet/ allows for this and it works nicely for the EventHubClient. Unfortunately, as I described in https://github.com/Azure/azure-event-hubs-dotnet/issues/210#issuecomment-418019549 they are unable to pass the IWebProxy further through to the creation of the CloudBlobClient. I would love to see consistent support for IWebProxy across the Azure libraries as clearly these are regularly used inside corporate environments and .NET Core adoption is only going to continue to grow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The specified framework 'Microsoft.AspNetCore.App' ...
NET Core SDK 2.1.300 is now available: https://www.microsoft.com/net/download/windows Install it, this fixed the problem for me.
Read more >
Download a blob with .NET - Azure Storage
This article shows how to download a blob using the Azure Storage client library for .NET. You can download blob data to various ......
Read more >
Solution to Visual Studio 2022 messing up ...
The error shown when attempting to load the projects was: The project file cannot be opened. Unable to locate the .NET SDK. Check...
Read more >
What's new in Web Development with ASP.NET Core 2.1
Your browser can't play this video. Learn more. Stroke of genius.
Read more >
.NET Core Guide
NET Core 3.0, see What's new in .NET Core 3.0. After installing the .NET Core SDK, open a command prompt. Type the following...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found