Google 云 API 未返回任何响应

Google Cloud API not returning any response

背景资料:
我正在尝试使用他们的 .NET library.

为 Google Cloud Vision API 创建一个 PoC

我做了什么:
使用以下代码为 Vision API 创建一个简单的控制台应用程序。

GoogleCredential credential = GoogleCredential.FromFile(ConfigurationManager.AppSettings["GoogleCredentialFile"]);
Grpc.Core.Channel channel = new Grpc.Core.Channel(Google.Cloud.Vision.V1.ImageAnnotatorClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials());
var client = Google.Cloud.Vision.V1.ImageAnnotatorClient.Create(channel);

var image = Google.Cloud.Vision.V1.Image.FromFile(@"C:\Users\u065340\Documents\sample.jpg");
var response = client.DetectLabels(image);
foreach (var annotation in response)
{
    if (annotation.Description != null)
    result = annotation.Description;
}

问题:
client.DetectLabels(image) 行在最终抛出错误 Deadline Exceeded.
之前卡住了很长时间 我的代码位于公司代理后面,但我已经验证它不会阻止互联网访问,因为我可以从相同的应用程序调用 https://vision.googleapis.com/$discovery/rest?version=v1 并得到它的 JSON 响应。
有什么建议吗?

按照 Jon Skeet 的建议深入研究 github 与代理相关的问题后,我发现 Google 云客户端 API 通常可以分为两类(参考:here ): 基于 REST 的 HTTP 1.1 JSON 和 gRPC.
对于关联为基于 REST 的 API,代理应该没有问题。当我们使用基于 gRPC 的 API(例如 Google Cloud Vision 和 Google Speech)时,问题开始出现。在gRPC中,我们需要显式提供我们的代理服务器信息。

对于那些使用Java客户端的人来说,似乎我们仍然无法正确设置代理,因为它最终会被忽略,并导致Deadline Exceeded错误。这个问题已经众所周知,可以在 here and further traced into here.
找到 Google团队确定确实是一个bug,状态保持为Open。

对于C#客户端,我们可以使用here中记录的gRPC环境变量来设置代理信息。密码是Environment.SetEnvironmentVariable("http_proxy", <your_proxy_server>);
在我将 http_proxy 环境变量设置为指向我的代理服务器后,一切都恢复正常了。我得到了预期的输出 "This API needs Billing Account"。

非常感谢 Jon Skeet 为我指明了正确的方向 :D