ResourceExhausted
dotnet
protocol_error
ai_generated
true
Grpc.Core.RpcException: 状态(StatusCode="ResourceExhausted", Detail="接收的消息大于最大值(4194304 vs. 4194304)")
Grpc.Core.RpcException: Status(StatusCode="ResourceExhausted", Detail="Received message larger than max (4194304 vs. 4194304)")
ID: dotnet/grpc-client-max-message-size
90%修复率
90%置信度
1证据数
2023-02-20首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| .NET 6.0 | active | — | — | — |
| .NET 7.0 | active | — | — | — |
| .NET 8.0 | active | — | — | — |
| Grpc.Net.Client 2.49+ | active | — | — | — |
| Grpc.AspNetCore 2.49+ | active | — | — | — |
根因分析
gRPC客户端或服务器默认最大消息大小为4 MB,响应负载超过此限制,导致通道拒绝。
English
The gRPC client or server has a default maximum message size of 4 MB, and the response payload exceeds this limit, causing the channel to reject it.
官方文档
https://learn.microsoft.com/en-us/aspnet/core/grpc/configuration?view=aspnetcore-8.0#configure-maximum-message-size解决方案
-
Increase MaxReceiveMessageSize on the client and MaxSendMessageSize on the server to a larger value (e.g., 10 MB) in the gRPC channel and service options.
-
Stream the large payload using server-streaming gRPC instead of unary calls to avoid hitting the message size limit.
无效尝试
常见但无效的做法:
-
Increasing the client's MaxReceiveMessageSize without adjusting the server's MaxSendMessageSize
70% 失败
Both client and server enforce limits; if only one side is increased, the other side still rejects the message.
-
Disabling compression on the gRPC channel to reduce message size
40% 失败
Compression reduces size but does not eliminate the hard limit; large payloads still exceed 4 MB.