【问题标题】:Grpc bi-directional stream was terminated by peer when stream call loop is big?当流调用循环很大时,Grpc 双向流被对等端终止?
【发布时间】:2021-04-27 14:54:00
【问题描述】:

我在客户端(dart)和服务器(.net)之间有双向流。当客户端有大流调用循环时我遇到了问题

在我得到的服务器上

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)

在客户端我得到

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

它在小流调用循环时工作。

我试图增加 MaxStreamsPerConnection 但还是不行

.ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.ConfigureKestrel(serveroption => {
        
                        serveroption.Limits.Http2.MaxStreamsPerConnection = 5000;
                    }).UseStartup<Startup>();
                });

【问题讨论】:

    标签: .net dart grpc


    【解决方案1】:

    我的应用程序使用 nginx 作为反向代理。原来是 nginx 网络服务器的问题。 我从 nginx 得到的错误

    客户端打算发送太大的分块正文:10489464 字节同时向上游发送请求,

    要解决这个问题,只需添加

    http {
        ...
        client_max_body_size 20M;
    }   
    

    Nginx error: client intended to send too large body

    【讨论】:

      猜你喜欢
      • 2019-04-08
      • 2020-09-30
      • 1970-01-01
      • 2022-11-03
      • 2018-09-20
      • 1970-01-01
      • 2018-08-30
      • 2021-11-01
      • 1970-01-01
      相关资源
      最近更新 更多