Our communication exceeds the default grpc-java limit on the message size:
Caused by: io.grpc.StatusRuntimeException: INTERNAL:
Frame size 4555602 exceeds maximum: 4194304.
If this is normal, increase the maxMessageSize
in the channel/server builder
That limit can be increased, see from https://github.com/grpc/grpc-java/issues/917:
Set maxMessageSize() on the Channel/Server builder.
When trying to implement the fix in our code base, however, it is not clear for me how to do that, as not all Channel
implementations have a maxMessageSize
method.
Our code uses a ManagedChannel
. The setup code looks like this:
ManagedChannel channel =
ManagedChannelBuilder.forAddress(rpcHost, grpcPort)
.usePlaintext(true).build();
CatalogGrpcServiceGrpc.CatalogGrpcServiceBlockingStub stub =
CatalogGrpcServiceGrpc.newBlockingStub(channel);
CatalogRetrieverGrpcServiceAdapter grpcServiceAdapter =
new CatalogRetrieverGrpcServiceAdapter(
stub, metricRegistry);
Maybe I am missing something, but I cannot see how to increase the maximum size for ManagedChannel
. Only the OkHttpChannelBuilder
has it (OkHttpChannelBuilder#maxMessageSize
).
Questions:
ManagedChannel
?ManagedChannel
, how can I rewrite the code to use another channel implementation that support to increase the default limit?Edit: You can now increase the limit directly from ManagedChannelBuilder
.
Today, you can't increase the limit on ManagedChannelBuilder
; you are forced to specify the transport implementation you want to use.
So most users would explicitly use NettyChannelBuilder
, and Android users would use OkHttpChannelBuilder
:
ManagedChannel channel =
NettyChannelBuilder.forAddress(rpcHost, grpcPort)
.usePlaintext(true).build();
I've created GitHub issue 2307 to track this.