# RESOURCE_EXHAUSTED: grpc: received message larger than max (5242880 vs. 4194304)

- **ID:** `grpc/grpc-message-too-large-client`
- **Domain:** grpc
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Client received a gRPC response message that exceeds the configured max receive message size.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| gRPC v1.48.0 | active | — | — |
| gRPC v1.56.0 | active | — | — |
| gRPC v1.62.0 | active | — | — |

## Workarounds

1. **Increase the client's max receive message size using grpc.max_receive_message_length option. Example in Python: channel = grpc.insecure_channel('localhost:50051', options=[('grpc.max_receive_message_length', 10 * 1024 * 1024)])** (90% success)
   ```
   Increase the client's max receive message size using grpc.max_receive_message_length option. Example in Python: channel = grpc.insecure_channel('localhost:50051', options=[('grpc.max_receive_message_length', 10 * 1024 * 1024)])
   ```
2. **Set the environment variable GRPC_MAX_RECEIVE_MESSAGE_LENGTH to a larger value (e.g., 10485760 for 10 MB) before starting the client process.** (85% success)
   ```
   Set the environment variable GRPC_MAX_RECEIVE_MESSAGE_LENGTH to a larger value (e.g., 10485760 for 10 MB) before starting the client process.
   ```
3. **Refactor the RPC to use streaming responses or pagination to avoid sending large messages in a single response.** (75% success)
   ```
   Refactor the RPC to use streaming responses or pagination to avoid sending large messages in a single response.
   ```

## Dead Ends

- **** — The error occurs on the client side; server-side changes alone don't fix client-side limits. (80% fail)
- **** — Compression may reduce size but doesn't guarantee it stays under the limit; also adds overhead. (60% fail)
- **** — The same large message will be received again unless the client limit is increased. (95% fail)
