gRPC消息超过最大大小4194304:5145024 java



在grpc客户端上,我在服务器中调用rpc方法后得到此错误。我使用grpc-spring-boot-starter (java)。请告诉我如何增加响应大小。

at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
  • 如果您使用的是官方grpc库,请按以下方式创建客户端
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 9089).usePlaintext().maxInboundMessageSize(Integer.MAX_VALUE).build();
productsBlockingStub prodStub = productsGrpc.newBlockingStub(channel);

你可以在这里引用grpc项目。只需添加修改formaxInboundMessageSize

  • 如果你使用的是grpc-client-spring-boot-starter,那么你可以选择。
@GrpcClient("greeting-service")
private GreetingServiceGrpc.GreetingServiceBlockingStub greetingServiceBlockingStub;
greetingServiceBlockingStub = greetingServiceBlockingStub.withMaxInboundMessageSize(Integer.MAX_VALUE);
greetingServiceBlockingStub = greetingServiceBlockingStub.withMaxOutboundMessageSize(Integer.MAX_VALUE);

或者在props中添加。

grpc.client.greeting-service.max-inbound-message-size=9155241000
grpc.client.greeting-service.package-max-inbound-message-size=9155241000
grpc.client.greeting-service.server.max-inbound-message-size=9155241000

最新更新