Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
619 views
in Technique[技术] by (71.8m points)

.net - Grpc bi-directional stream was terminated by peer when stream call loop is big?

I have bi directional stream between client (dart) and server (.net). I got problem when client have big stream call loop

on server i get

System.IO.IOException: The request stream was aborted.
---> Microsoft.AspNetCore.Connections.ConnectionAbortedException: The HTTP/2 connection faulted.
  --- End of inner exception stack trace ---
  at System.IO.Pipelines.PipeCompletion.ThrowLatchedException()
  at System.IO.Pipelines.Pipe.GetReadResult(ReadResult& result)
  at System.IO.Pipelines.Pipe.GetReadAsyncResult()
  at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.Http2MessageBody.ReadAsync(CancellationToken cancellationToken)
  at Grpc.AspNetCore.Server.Internal.PipeExtensions.ReadStreamMessageAsync[T](PipeReader input, HttpContextServerCallContext serverCallContext, Func`2 deserializer, CancellationToken cancellationToken)

and on client i get

gRPC Error (code: 2, codeName: UNKNOWN, message: HTTP/2 error: Stream error: Stream was terminated by peer (errorCode: 2)., details: null)

its working when small stream call loop.

i tried to increase MaxStreamsPerConnection but still not working

.ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.ConfigureKestrel(serveroption => {
        
                        serveroption.Limits.Http2.MaxStreamsPerConnection = 5000;
                    }).UseStartup<Startup>();
                });
question from:https://stackoverflow.com/questions/65857026/grpc-bi-directional-stream-was-terminated-by-peer-when-stream-call-loop-is-big

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

My app using nginx as reverse proxy. It's turn out to be problem from nginx webserver. the error i get from nginx

client intended to send too large chunked body: 10489464 bytes while sending request to upstream, 

to fix this just add

http {
    ...
    client_max_body_size 20M;
}   

Nginx error: client intended to send too large body


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...