我们的通信超出了grpc-java对消息大小的默认限制:
Caused by: io.grpc.StatusRuntimeException: INTERNAL:
Frame size 4555602 exceeds maximum: 4194304.
If this is normal, increase the maxMessageSize
in the channel/server builder
可以增加该限制,请参阅https://github.com/grpc/grpc-java/issues/917:
在 Channel/Server 构建器上设置 maxMessageSize()。
然而,当尝试在我们的代码库中实现修复时,我不清楚如何做到这一点,因为并非所有Channel
实现都有maxMessageSize
方法。
我们的代码使用ManagedChannel
. 设置代码如下所示:
ManagedChannel channel =
ManagedChannelBuilder.forAddress(rpcHost, grpcPort)
.usePlaintext(true).build();
CatalogGrpcServiceGrpc.CatalogGrpcServiceBlockingStub stub =
CatalogGrpcServiceGrpc.newBlockingStub(channel);
CatalogRetrieverGrpcServiceAdapter grpcServiceAdapter =
new CatalogRetrieverGrpcServiceAdapter(
stub, metricRegistry);
也许我遗漏了一些东西,但我看不到如何增加ManagedChannel
. 只有OkHttpChannelBuilder
有它 ( OkHttpChannelBuilder#maxMessageSize
)。
问题:
- 如何使用 增加消息限制
ManagedChannel
? - If it is not possible with
ManagedChannel
, how can I rewrite the code to use another channel implementation that support to increase the default limit?