我正在尝试调用Google的AnalyzeSentiment API,并在调用后等待约10分钟后,持续超过截止日期的异常。
该项目位于C#点网核心2.2上。我使用dot net framework 4.6.2尝试了相同的操作,并遇到了相同的异常。
using System;
using Google.Cloud.Language.V1;
namespace TestSentiment1
{
public class Program
{
public static void Main(string[] args)
{
//Set Environment variable GOOGLE_APPLICATION_CREDENTIALS
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", @"C:\\Users\\XXXXXX\\Downloads\\TestSentiment1-xxxxxxxx.json");
// The text to analyze.
string text = "Hello World!";
var client = LanguageServiceClient.Create();
//Throws deadline exceeded exception here
var response = client.AnalyzeSentiment(new Document()
{
Content = text,
Type = Document.Types.Type.PlainText
});
var sentiment = response.DocumentSentiment;
Console.WriteLine($"Score: {sentiment.Score}");
Console.WriteLine($"Magnitude: {sentiment.Magnitude}");
}
}
}
下面的异常是我得到的
在Grpc.Core.Internal.AsyncCall 2.UnaryCall(TRequest msg) in T:\src\github\grpc\src\csharp\Grpc.Core\Internal\AsyncCall.cs:line 78
at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method
2方法,字符串宿主,CallOptions选项,TRequest请求中)在T:\ src \ github \ grpc \ src \ csharp \ Grpc.Core \ DefaultCallInvoker.cs中: 46行
在Grpc.Core.Interceptors.InterceptingCallInvoker.b__3_0 [TRequest,TResponse](TRequest要求,ClientInterceptorContext 2 ctx) in T:\src\github\grpc\src\csharp\Grpc.Core\Interceptors\InterceptingCallInvoker.cs:line 51
at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext
2上下文,BlockingUnaryCallContinuation 2 continuation) in T:\src\github\grpc\src\csharp\Grpc.Core\ClientBase.cs:line 174
at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method
2方法,字符串主机,CallOptions选项,TRequest请求)中: src \ github \ grpc \ src \ csharp \ Grpc.Core \ Interceptors \ InterceptingCallInvoker.cs:第48行
在T:\ src \ github \ google-cloud-dotnet \ releasebuild \ apis \ Google.Cloud.Language.V1.Google.Cloud中的Google.Cloud.Language.V1.LanguageService.LanguageServiceClient.AnalyzeSentiment(AnalyzeSentimentRequest请求,CallOptions选项)中.Language.V1 \ LanguageServiceGrpc.cs:第218行
在C:\ Users \ skeet \ Test \ Projects \ gax-dotnet \ releasebuild \ Google.Api.Gax中的Google.Api.Gax.Grpc.ApiCall.GrpcCallAdapter 2.CallSync(TRequest request, CallSettings callSettings) in C:\Users\skeet\Test\Projects\gax-dotnet\releasebuild\Google.Api.Gax.Grpc\ApiCall.cs:line 92
at Google.Api.Gax.Grpc.ApiCallRetryExtensions.<>c__DisplayClass1_0
2.b__0(TRequest请求,CallSettings呼叫设置) .Grpc \ ApiCallRetryExtensions.cs:第84行