問題一:
Grpc.Core.RpcException: Status(StatusCode=Unavailable, Detail="Connection reset by peer") at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg) at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request) at Grpc.Core.Interceptors.InterceptingCallInvoker.<BlockingUnaryCall>b__3_0[TRequest,TResponse](TRequest req, ClientInterceptorContext`2 ctx) at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext`2 context, BlockingUnaryCallContinuation`2 continuation)
解決方案:
private readonly Polly.Retry.RetryPolicy RetryPolicy = Policy .Handle<RpcException>(t => t.Status.StatusCode == StatusCode.Unavailable) .Retry(1);
var server = new Server(new List<ChannelOption> { new ChannelOption("grpc.keepalive_time_ms", 800000), // 傳送 keepalive 探測訊息的頻度 new ChannelOption("grpc.keepalive_timeout_ms", 5000), // keepalive 探測應答超時時間 new ChannelOption("grpc.keepalive_permit_without_calls", 1) // 是否允許在沒有任何呼叫時傳送 keepalive }) { Services = { ServiceA }, Ports = { new ServerPort(host, port, ServerCredentials.Insecure) }, };
問題二:
解決方案:
var channelOptions = new List<ChannelOption>();
// add max message length option 設最大接收數量 channelOptions.Add(new ChannelOption(ChannelOptions.MaxReceiveMessageLength, (4 * 1024 * 1024) * 7))
|
|
|
|
|
|
|
|
|
|
如果您覺得閱讀本文對您有幫助,請點一下“推薦”按鈕,您的“推薦”將是我最大的寫作動力!
本文版權歸作者和部落格園共有,來源網址:https://www.cnblogs.com/DanielYao/歡迎各位轉載,但是未經作者本人同意,轉載文章之後必須在文章頁面明顯位置給出作者和原文連線,否則保留追究法律責任的權利。