Grpc is a cross-platform remote call framework, for the first time in the Windows platform, there are a lot of problems to face, a summary of the following to prepare for inspection
Problem with message length setting 1
Client exception occurred
Unhandled exception: Grpc.Core.RpcException:Status (statuscode=internal, detail= "Max message size exceeded") in System.Runtime.Comp IlerServices.TaskAwaiter.ThrowForNonSuccess (Task Task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task Task) in Grpc.Core.Internal.AsyncCall ' 2.UnaryCall (trequest msg) in Grpc.core.calls.blockingunarycall[trequest,tresponse] ( Callinvocationdetails ' 2 call, Trequest req) in Grpc.core.defaultcallinvoker.blockingunarycall[trequest,tresponse] ( Method ' 2 method, String host, calloptions options, trequest request) in Grpc.Core.Internal.InterceptingCallInvoker.Block Ingunarycall[trequest,tresponse] (method ' 2 method, String host, calloptions options, trequest request) in Helloworld.gree ter. Greeterclient.getusers (searchuserrequest request, calloptions options) Location E:\MyTest\grpc-1.0.x\examples\csharp\ Helloworld\greeter\helloworldgrpc.cs: Line number 148 at Helloworld.Greeter.GreeterClient.GetUsers (searchuserrequest request, Metadata headers, NUllable ' 1 deadline, CancellationToken cancellationtoken) Location E:\MyTest\grpc-1.0.x\examples\csharp\helloworld\Greeter \helloworldgrpc.cs: Line number 144 in GreeterClient.Program.Main (string[] args) location E:\MyTest\grpc-1.0.x\examples\csharp\ Helloworld\greeterclient\program.cs: Line No. 61
An exception occurred on the service side
W1024 09:50:02.749888 Grpc.Core.Server Exception while handling RPC. System.InvalidOperationException: Error sending status from server. 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) 在 Grpc.Core.Internal.UnaryServerCallHandler`2.<HandleCall>d__0.MoveNext()--- 引发异常的上一位置中堆栈跟踪的末尾 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 Grpc.Core.Server.<HandleCallAsync>d__11.MoveNext()
# # Problem 2
An exception occurred on the client
Unhandled exception: Grpc.Core.RpcException:Status (statuscode=internal, detail= "{" Created ":" @1477274209.883000000 "," Description ":" Rst_stream "," File ":" C:\jenkins\workspace\gRPC_build_artifacts\architecture\x86\language\csharp\ Platform\windows\vsprojects\. \src\core\ext\transport\chttp2\transport\frame_rst_stream.c "," File_line ": 107," Http2_error ": 2}") in System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Task Task) in System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Task Task) in Grpc.Core.Internal.AsyncCall ' 2.UnaryCall (trequest msg) in Grpc.core.calls.blockingunarycall[trequest,tresponse] ( Callinvocationdetails ' 2 call, Trequest req) in Grpc.core.defaultcallinvoker.blockingunarycall[trequest,tresponse] ( Method ' 2 method, String host, calloptions options, trequest request) in Grpc.Core.Internal.InterceptingCallInvoker.Block Ingunarycall[trequest,tresponse] (method ' 2 method, String host, calloptions options, trequest request) in Helloworld.gree ter. GreeTerclient.getusers (searchuserrequest request, calloptions options) Location E:\MyTest\grpc-1.0.x\examples\csharp\ Helloworld\greeter\helloworldgrpc.cs: Line number 148 at Helloworld.Greeter.GreeterClient.GetUsers (searchuserrequest request, Metadata headers, Nullable ' 1 deadline, CancellationToken cancellationtoken) Location E:\MyTest\grpc-1.0.x\examples\csharp\ Helloworld\greeter\helloworldgrpc.cs: Line number 144 in GreeterClient.Program.Main (string[] args) location E:\MyTest\grpc-1.0.x\ Examples\csharp\helloworld\greeterclient\program.cs: Line No. 71
An exception occurred on the server
W1024 09:56:49.886636 Grpc.Core.Internal.UnaryServerCallHandler ' 2 Exception occured in Handler. System.ArgumentException: The value is not in the expected range. In Grpc.Core.Internal.UnaryServerCallHandler ' 2.
WorkaroundThis problem occurs when GRPC limits the default message size (massage size), the value of the limit is not quite the same in each version, in order to make the GRPC more efficient, the developer thinks should not be too big, 4M more appropriate.
But in practical application, although it can be stipulated that writing contract is reasonable, but there will be many large objects.
The workaround is to manually set the value of the messagesize.
Issue 1 is that the client cannot resolve after the client has set messagesize and received a large object. Issue 2 is that messagesize is not set on the server side and the server cannot resolve the message sent.
Code required on the service side
Varoptions = new list< channeloption> {new (channeloptions. Maxmessagelength,int. Maxvalue) }; channel channel = new Channel< Span class= "P" > ( "127.0.0.1:50051" channelcredentials insecureoptions);
Code required on the client
ServerServer=NewServer(NewList<Channeloption>{NewChanneloption(Channeloptions.maxmessagelengthint. Maxvalue) }) {services = {greeter. Bindservice (new greeterimpl ()) }, ports = {new serverport ( "localhost" port Servercredentials. Insecure) } };
In the end this value is set to how much reasonable if set to int. MaxValue, what impact on performance, in the later use gradually realized.
C # using GRPC issues Rollup