我们正在尝试实现 GRPC 代理服务器(ASP.NET Core 控制台应用程序),它将传入数据代理到 Google Speech 流 api。代码与中几乎相同示例应用程序 https://cloud.google.com/speech/docs/streaming-recognize.
代理服务器的目的是多语言识别和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 : server stops at this line. Client therefore gets deadline exception.
事实证明,问题出在服务器端,由于异步操作而出现死锁。
解决方案已描述here https://olitee.com/2015/01/c-async-await-common-deadlock-scenario/
异步操作上的configureAwait(false) 解决了这个问题。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)