.net - 当流调用循环很大时,Grpc 双向流被对等端终止?
问题描述
我在客户端(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>();
});
解决方案
我的应用程序使用 nginx 作为反向代理。原来是 nginx 网络服务器的问题。我从 nginx 得到的错误
客户端打算发送太大的分块正文:10489464 字节,同时向上游发送请求,
要解决这个问题,只需添加
http {
...
client_max_body_size 20M;
}
推荐阅读
- c++ - 在构造函数中复制通过引用传递的向量
- javascript - 获取div的滚动进度
- python - 更改表格中的字体大小 - 使用 DocX 的 Python
- python-3.x - 在 Ubuntu 18.04.2 LTS docker 容器上使用 Python 3.6.8 的机器人框架
- javascript - 如何从此箭头函数返回 pkgInfo 对象?
- excel - 引用包含 volatile 函数的单元格是否比在多个公式中包含该函数更有效?
- java - 如何在 IntelliJ 和 Linux 上正确安全地运行 tomcat
- javascript - 转换后水平滚动菜单粘连:应用 translate(X),是否可以检测用户何时向上滚动超过 ID?
- python - 试图找出如何以可重复的方式使用 python 或 javascript 生成合成数据集
- python - str(Series).split() 和 Series.str.split() 有什么区别?