I have a Spring Boot micro-service which listens through GRPC using LogNet/grpc-spring-boot-starter
By default GRPC payload maximum size is 4MB. At client side, it's easy to set the response payload size, but I want to increase the request size at the server side.
At client side,
ManagedChannel channel =
NettyChannelBuilder.forAddress(...)
.maxInboundMessageSize(NEW_MAX_MESSAGE_SIZE).build();
By server code:
@GRpcService
public class FooService extends FooServiceImplBase {
@Override
public void foo(GetRequest request, StreamObserver<GetResponse> responseObserver) {
...
}
}
Define a ServerBuilderConfigurer like this:
@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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.