ResourceExhausted
dotnet
protocol_error
ai_generated
true
Grpc.Core.RpcException: Status(StatusCode="ResourceExhausted", Detail="Received message larger than max (4194304 vs. 4194304)")
ID: dotnet/grpc-client-max-message-size
90%Fix Rate
90%Confidence
1Evidence
2023-02-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| .NET 6.0 | active | — | — | — |
| .NET 7.0 | active | — | — | — |
| .NET 8.0 | active | — | — | — |
| Grpc.Net.Client 2.49+ | active | — | — | — |
| Grpc.AspNetCore 2.49+ | active | — | — | — |
Root Cause
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.
generic中文
gRPC客户端或服务器默认最大消息大小为4 MB,响应负载超过此限制,导致通道拒绝。
Official Documentation
https://learn.microsoft.com/en-us/aspnet/core/grpc/configuration?view=aspnetcore-8.0#configure-maximum-message-sizeWorkarounds
-
95% success 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.
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.
-
85% success Stream the large payload using server-streaming gRPC instead of unary calls to avoid hitting the message size limit.
Stream the large payload using server-streaming gRPC instead of unary calls to avoid hitting the message size limit.
中文步骤
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.
Dead Ends
Common approaches that don't work:
-
Increasing the client's MaxReceiveMessageSize without adjusting the server's MaxSendMessageSize
70% fail
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% fail
Compression reduces size but does not eliminate the hard limit; large payloads still exceed 4 MB.