google-cloud-dotnet icon indicating copy to clipboard operation
google-cloud-dotnet copied to clipboard

StorageClient.DownloadObject is throwing System.Net.Http.HttpRequestException: No such host is known. (storage.googleapis.com:443) error

Open vpdsouza opened this issue 8 months ago • 7 comments

I use the StorageClient API to list objects, upload objects and download objects. It is working just fine when I try from my laptop but when deployed to Windows Server 2016, I was seeing the above error. Therefore, I requested the Proxy account for my App. Once that is setup, I added the proxy to StorageClient's InnerHandler as specified in this article.

However, this works just fine for listing the objects and upload the objects but it still does not work for DownloadObject. For some reason it still throws the "No such host is known. (storage.googleapis.com:443)" when I make the call to DownloadObject. If I go by amanda-tarafa post I cannot even call List Objects and get the same error.

That said, can anyone tell me why the DownloadOject does not use the proxy that is set in either inner handler or using HttpClientFactory? The code used to set the proxy is as sampled by jskeet and also by amanda-tarafa but nothing works for DownloadObject.

I greatly appreciate if you could help me solve this mystery.

-Vincent D'Souza

Here is the error: System.Net.Http.HttpRequestException: No such host is known. (storage.googleapis.com:443) ---> System.Net.Sockets.SocketException (11001): No such host is known. at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|285_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at Google.Apis.Http.ConfigurableMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Google.Apis.Download.MediaDownloader.DownloadCoreAsync(String url, Stream stream, CancellationToken cancellationToken) at Google.Apis.Download.DownloadProgress.ThrowOnFailure(IDownloadProgress progress)

vpdsouza avatar Apr 01 '25 17:04 vpdsouza

In principle, the download operations use the same HttpClient that's used for all the other operations, so download operations should work with a proxy once you've created the StorageClient as desribed in https://github.com/googleapis/google-cloud-dotnet/issues/1832#issuecomment-930057930. Please confirm this is how you are creating the client.

Else you might want to check network logs to see why the download operation is not working.

And for us to be able to help you further, you'd need to provide us with a minimal but complete console application that reproduces the issues you are seeing.

Assigning to @danielduhh for further triage for diagnosing.

amanda-tarafa avatar Apr 01 '25 18:04 amanda-tarafa

Thanks Amanda, we can take a look

danielduhh avatar Apr 01 '25 21:04 danielduhh

Good afternoon!

Amanda, I have attached the POC project with 4 scenarios. Also, just wanted to let you know that all these scenarios tried on Windows Server 2016 from the Data Center where I need to use the proxy to connect to GCP. From my laptop, it works just fine without setting the proxy.

I am attaching the log files with different responses.

log2025040208-Factory.txt log2025040212-NonFactory-GetByteArrayAsync.txt log2025040213-Factory-GetByteArrayAsync.txt log2025040213-NonFactoryDownload.txt

POC.zip

  1. Using Non-Factory approach by setting the Proxy to inner handler
    1. by Calling DownloadFileAsGetByteArrayAsync() works just fine but not sure about the performance, I have not tested it thoroughly.
    2. DownloadObjectAsync Fails
  2. Using your Factory approach - Nothing works for both the scenarios

Hope, this helps. I have not attached the proprietary information, so, please add the appSettings.json and SA.json of your GCP project.

vpdsouza avatar Apr 02 '25 18:04 vpdsouza

@amanda-tarafa , @danielduhh Any progress/updates on this issue?

vpdsouza avatar Apr 07 '25 16:04 vpdsouza

Thanks for providing the sample code! Looking at it locally, I can see that when running it with the Factory setup, the library definitely is trying to use the provided proxy. Based on the logs you gave us, you don't end up getting an Auth token, so I think what's going on here is that the Proxy you're using isn't correctly configured. I don't think you gave us the actual Proxy you're using (your code just has "ProxyURI" for the address), but the Proxy may not be constructed correctly, or it may be that the proxy you're trying to connect with isn't configured to be able to access GCS. Do you have full control over the Proxy you're trying to use? Are you able to make sure that it's correctly configured to connect to GCS, auth, open for streaming, etc.?

JesseLovelace avatar Apr 08 '25 23:04 JesseLovelace

Do you have full control over the Proxy you're trying to use? Are you able to make sure that it's correctly configured to connect to GCS, auth, open for streaming, etc.?

@JesseLovelace @danielduhh @amanda-tarafa

No, I am in a corporate world. So, I have no direct access to corporate servers. However, I can guarantee that proxy is setup correctly because initially I was unable to connect to GCS at all but after setting up the proxy for "storage.googleapis.com" I was able to not only list the objects but also upload the objects and store the objects in GCS folder using non-factory method.

The only issue now there is, I am unable to download the same stored objects from GCS.

I have two processes, one process to get the files from sftp and then upload to them to GCS. In the next process I download those objects from GCS to put them in MQ queue.

Yes, I did not include my proxy information because it is irrelevant outside of our corporate network and also it is proprietary information.

vpdsouza avatar Apr 21 '25 16:04 vpdsouza

Quad9 / 9.9.9.9 can't resolve storage.googleapis.com for me right now, but Cloudflare 1.1.1.1 and Google DNS 8.8.8.8 resolves it just fine.

UTC now is 2025-10-19T16:41:32.6237751Z.

Seems there might be some issue with DNS propagation?


Edit: I sent an email to Quad9 support ( https://quad9.net/support/contact/ ).

o-l-a-v avatar Oct 19 '25 16:10 o-l-a-v