# grpc::RpcError: message too large (exceeds 4 MB limit)

- **ID:** `communication/grpc-message-size-exceeded`
- **Domain:** communication
- **Category:** protocol_error
- **Error Code:** `RESOURCE_EXHAUSTED`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

gRPC default maximum message size is 4 MB for both send and receive; any message exceeding this limit causes a RpcError.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| gRPC 1.48.0 | active | — | — |
| gRPC 1.50.0 | active | — | — |
| gRPC 1.54.0 | active | — | — |

## Workarounds

1. **Increase max message size on both client and server: server: server = grpc.server(futures.ThreadPoolExecutor(max_workers=10), options=[('grpc.max_send_message_length', 10 * 1024 * 1024), ('grpc.max_receive_message_length', 10 * 1024 * 1024)]) client: channel = grpc.insecure_channel('localhost:50051', options=[('grpc.max_send_message_length', 10 * 1024 * 1024), ('grpc.max_receive_message_length', 10 * 1024 * 1024)])** (95% success)
   ```
   Increase max message size on both client and server: server: server = grpc.server(futures.ThreadPoolExecutor(max_workers=10), options=[('grpc.max_send_message_length', 10 * 1024 * 1024), ('grpc.max_receive_message_length', 10 * 1024 * 1024)]) client: channel = grpc.insecure_channel('localhost:50051', options=[('grpc.max_send_message_length', 10 * 1024 * 1024), ('grpc.max_receive_message_length', 10 * 1024 * 1024)])
   ```
2. **Split the large payload into multiple smaller messages using client-side chunking, then reassemble on server** (85% success)
   ```
   Split the large payload into multiple smaller messages using client-side chunking, then reassemble on server
   ```
3. **Use gRPC streaming (server-side or bidirectional) to send data in chunks without changing limits** (90% success)
   ```
   Use gRPC streaming (server-side or bidirectional) to send data in chunks without changing limits
   ```

## Dead Ends

- **** — Server still enforces default limit, so server-side deserialization fails (95% fail)
- **** — gRPC compression reduces wire size but server still checks uncompressed size (70% fail)
- **** — Streaming works but requires protocol change and breaks existing clients; not a direct fix (60% fail)
