问题
We are trying to implement GRPC proxy server ( ASP.NET Core console app ) which will proxy incoming data to Google Speech streaming api. Code is pretty much the same as in sample application.
Proxy server purpose is multiple language recognition and api key protection.
For testing purpose I have created Windows forms application which sends available data ( audio chunks via DataAvailable handler ) to proxy server. Server starts recognizing transcripts, but after few recognitions ( approximately 5-10 ), it is not responding anymore. Actually every call from client to proxy server timeouts ( deadlines ).
On the client I am receiving next exception:
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.
回答1:
It turned out, the problem was on server side with deadlocks because of asynchronous operations.
The solution is described here
configureAwait(false) on asynchronous operations solved the problem then.
来源:https://stackoverflow.com/questions/45484096/grpc-proxy-server-for-google-speech-streaming-api-is-not-responding-grpc-core