简体   繁体   English

Grpc.Core.RpcException StatusCode Unavailable Channel 处于状态 TRANSIENT_FAILURE

[英]Grpc.Core.RpcException StatusCode Unavailable Channel is in state TRANSIENT_FAILURE

I am using Google Vision API to get associated labels for an image.我正在使用 Google Vision API 获取图像的关联标签。

 var client = ImageAnnotatorClient.Create();
 var image = Image.FromFile(@"C:\Users\Scorpio\Desktop\th.jpg");
 var response = client.DetectLabels(image); // error
 foreach (var annotation in response)
 {
     if (annotation.Description != null)
           Console.WriteLine(annotation.Description);
 }

在此处输入图片说明

Any idea how can we resolve this issue?知道我们如何解决这个问题吗? I tried using very common images like country flags but still it gives error.我尝试使用非常常见的图像,如国旗,但仍然出错。

I just replicate this scenario by using your code and it ran successfully.我只是使用您的代码复制了这个场景,它运行成功。 Based on this, it is possible that this issue was related to a temporary and transient error from the service side, as mentioned in the error message;基于此,此问题可能与服务端的暂时性和暂时性错误有关,如错误消息中所述; however, I recommend you to verify you are adding the correct libraries.但是,我建议您验证是否添加了正确的库。

Below is the code I used to perform the testing which includes the authentication process:下面是我用来执行测试的代码,其中包括身份验证过程:

using Google.Cloud.Vision.V1;
using System;
using Grpc.Auth;
using Google.Apis.Auth.OAuth2;

namespace VisionDemo
{
    class Program
    {   
        static void Main(string[] args)
        {
            //Authenticate to the service by using Service Account
            var credential = GoogleCredential.FromFile(@"<CREDENTIALS_JSON_FILE_PATH>").CreateScoped(ImageAnnotatorClient.DefaultScopes);
            var channel = new Grpc.Core.Channel(ImageAnnotatorClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials());
            // Instantiates a client
            var client = ImageAnnotatorClient.Create(channel);
            var image = Image.FromFile(@"<IMAGE_PATH>");
            var response = client.DetectLabels(image); // error
            foreach (var annotation in response)
            {
                if (annotation.Description != null)
                    Console.WriteLine(annotation.Description);
            }

        }
    }
}

In case you continue having this issue, you could take a look the Issue Tracker tool that you can use to raise a Vision API in order to verify this scenario with the Google Technical Support Team and check if this behavior can being generated with an issue on your project.如果您继续遇到此问题,您可以查看问题跟踪器工具,您可以使用该工具提出Vision API ,以便与 Google 技术支持团队验证此场景,并检查是否可以在出现问题时生成此行为你的项目。

 Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", @"C:\Users\#YOURUSER#\source\repos\PdfToImage\credentials.json");

I bumped into the same issue.我遇到了同样的问题。 Found the root cause and fixed it.找到根本原因并修复它。

Issue is due to Nuget package: Grpc.Core.Api This package got updated to version: 2.25.0, whereas Grpc.Core is blocked at version 1.22.1 due to Google.Api.Gax.Grpc 2.10.0问题是由于 Nuget 包:Grpc.Core.Api 此包已更新到版本:2.25.0,而 Grpc.Core 由于 Google.Api.Gax.Grpc 2.10.0 而在版本 1.22.1 中被阻止

Nothing stops you from updating Grpc.Core.Api to 2.25.0 version and then face the weird issue - client.Detect... methods not returning success or error, nothing (I didnt wait for 20 mins).没有什么能阻止你将 Grpc.Core.Api 更新到 2.25.0 版本,然后面对奇怪的问题 - client.Detect ... 方法不返回成功或错误,什么都没有(我没有等 20 分钟)。

Solution Grpc.Core.Api - bring the version number back to 1.22.1解决方案Grpc.Core.Api - 将版本号调回 1.22.1

Hope that helps!希望有帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Grpc.Core.RpcException:'状态(状态代码=“不可用”,详细信息=“空更新”, - Grpc.Core.RpcException: 'Status(StatusCode=“Unavailable”, Detail=“Empty update”, Grpc.Core.RpcException: 'Status (StatusCode = "Unavailable", Detail = "Error starting gRPC call - Grpc.Core.RpcException: 'Status (StatusCode = "Unavailable", Detail = "Error starting gRPC call 为什么要通过Google Cloud Firestore 1.0.0-beta05 C#SetAsync获取Grpc.Core.RpcException StatusCode =不可用,Detail =“连接失败”? - Why getting Grpc.Core.RpcException StatusCode=Unavailable, Detail=“Connect Failed”, with Google Cloud Firestore 1.0.0-beta05 C# SetAsync? Google Vision API无法正常运行Grpc.Core.RpcException - Google Vision API not working Grpc.Core.RpcException 从 .NET MAUI 应用程序调用 gRPC 服务时出现 Grpc.Core.RpcException - Grpc.Core.RpcException when calling gRPC service from .NET MAUI app Grpc.Core.RpcException 方法未在 C# 客户端和 Java 服务器中实现 - Grpc.Core.RpcException method is unimplemented with C# client and Java Server Grpc.Core.RpcException“无法反序列化响应消息..”或“InvalidOperationException:长度不匹配” - Grpc.Core.RpcException "Failed to deserialize response message.." or "InvalidOperationException: Length mismatch" 从ASP.NET在本地访问Google Cloud Datastore会引发Grpc.Core.RpcException:“缺少权限或权限不足。” - Accessing Google Cloud Datastore locally from ASP.NET throws Grpc.Core.RpcException: “Missing or insufficient permissions.” C# 程序将数据保存到 Google FirestoreDB 在某些计算机上失败(状态代码=不可用;grpc_status:14) - C# Program saving data to Google FirestoreDB fails on some computers (StatusCode=Unavailable; grpc_status: 14) 在 Net Core 3.0 中同时使用 GRPC 通道 - An using GRPC Channel concurrently in Net Core 3.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM