用于Google语音流API的Grpc代理服务器没有响应(Grpc.Core.RpcException)

时间:2017-08-03 12:23:20

标签: asp.net-core grpc google-speech-api

我们正在尝试实施GRPC代理服务器(ASP.NET核心控制台应用程序),它将传入的数据代理到Google Speech streaming api。代码与sample application中的代码几乎相同。

代理服务器的目的是多语言识别和api密钥保护。

出于测试目的,我创建了Windows表单应用程序,它将可用数据(通过DataAvailable处理程序的音频块)发送到代理服务器。服务器开始识别成绩单,但经过几次识别(大约5-10)后,它就不再响应了。实际上每次从客户端调用代理服务器超时(截止日期)。

在客户端,我收到下一个例外:

    Grpc.Core.RpcException: Status(StatusCode=DeadlineExceeded, Detail="Deadline Exceeded")
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg)
   at Grpc.Core.Calls.BlockingUnaryCall[TRequest,TResponse](CallInvocationDetails`2 call, TRequest req)
   at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
   at Grpc.Core.Internal.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)

EDIT1:服务器在此行停止。客户因此得到截止日期异常。 enter image description here

1 个答案:

答案 0 :(得分:0)

事实证明,由于异步操作,问题出在服务器端,导致死锁。

解决方案描述为here

configureAwait(false)对异步操作解决了问题。