我有一个Spring Boot微服务,它使用LogNet/grpc-spring-boot-starter通过GRPC进行监听
默认情况下,GRPC有效负载的最大大小为4MB。在客户端,设置响应负载大小很容易,但我想在服务器端增加请求大小。
在客户端,
ManagedChannel channel = 
   NettyChannelBuilder.forAddress(...)
                        .maxInboundMessageSize(NEW_MAX_MESSAGE_SIZE).build();按服务器代码:
@GRpcService
public class FooService extends FooServiceImplBase {
  @Override
  public void foo(GetRequest request, StreamObserver<GetResponse> responseObserver) {
    ...
  }
}发布于 2020-07-09 22:55:13
像这样定义一个ServerBuilderConfigurer:
@Component
public class FooServerBuilderConfigurer extends GRpcServerBuilderConfigurer {
  public static final int NEW_MAX_MESSAGE_SIZE = 100 * 1024 * 1024; // 100MB
  @Override
  public void configure(ServerBuilder<?> serverBuilder) {
    serverBuilder.maxInboundMessageSize(NEW_MAX_MESSAGE_SIZE);
  }
}https://stackoverflow.com/questions/62817713
复制相似问题