Changing maximum response size (getting error RESOURCE EXHAUSTED: Compressed gRPC message exceeds maximum size 4194304)

Hi, great work on this library. I’m currently using the scala client and server both generated using this version 0.7.1. I’m occasionally getting errors like this returned from the service:

io.grpc.StatusRuntimeException: RESOURCE_EXHAUSTED: Compressed gRPC message exceeds maximum size 4194304: 4196022 bytes read

Here’s what it looks like in intelij’s debugger:

So assuming that’s in bytes, that’s a max response size of about 4 mb. It would be great if I could bump that up to about 32 mb. I’ve done some googling but I can’t figure out if this is a setting on the client or server side, and, more importantly, I’m not sure how I’d change it.

Appreciate any tips.

I am not sure if this helps but I just found this while reading the docs. Under the “Streaming service Client Configuration” it mentions changing the maximum size for messages. here is the docs link

Thanks @AkashicSeer. I’m glad you reminded me to post here.

I ended up figuring it out shortly after posting by digging into the underlying grpc-netty client setup.

Here’s how you’d set it to 32 mb using a channel builder override.

val settings = GrpcClientSettings
      .withChannelBuilderOverrides(_.maxInboundMessageSize((32 * 1e6).toInt))
val client = MyServiceClient(settings)

I confirmed it respects the config by setting it to 1mb and making sure it crashed with an error message reflecting the change.


Thanks for posting this I am sure I will run into this problem soon.

Quick note: to adjust this same setting in Python you should do the following:

channel = insecure_channel("localhost:50051", options=[
    ('grpc.max_send_message_length', int(32e9)), # 32mb
    ('grpc.max_receive_message_length', int(32e9)), # 32mb
client = MyServiceStub(channel)

It’s important to cast the the value as int. Otherwise python’s scientific notation returns a float and grpc seems to ignore the setting.