【发布时间】:2016-09-28 17:09:30
【问题描述】:
我们的通信超出了默认的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增加消息限制? - 如果无法使用
ManagedChannel,我该如何重写代码以使用支持增加默认限制的另一个通道实现?
【问题讨论】: