Hi! We’re on kotlinx-rpc 0.11.0-grpc-189 and need ...
# kotlinx-rpc
v
Hi! We’re on kotlinx-rpc 0.11.0-grpc-189 and need to raise the inbound message size on the server, as we currently we hit the gRPC default:
Copy code
RESOURCE_EXHAUSTED: gRPC message exceeds maximum size 4194304
GrpcServer { }
/
GrpcServerConfiguration
doesn't expose
maxInboundMessageSize
, and `GrpcServerImpl`'s constructor is internal, so we can't pass a configured
ServerBuilder
. Is there a supported way to set the max grpc size? Would it make sense to just expose the
ServerBuilder
? Or would github.com/Kotlin/kotlinx-rpc/pull/754 be the official fix for this, and I'm just a few weeks ahead of train? I'll put my current workaround in the thread 🧵.
Workaround: a
ServerProvider
that wraps
NettyServerBuilder
and sets
maxInboundMessageSize
, registered via
META-INF/services/io.grpc.ServerProvider
with priority
10
so it wins over grpc-netty (
5
). kotlinx-rpc still calls
ServerBuilder.forPort(port)
, so the limit applies.
Copy code
kotlin
class LargeMessageServerProvider : ServerProvider() {
    override fun isAvailable(): Boolean = true
    override fun priority(): Int = 10

    override fun builderForPort(port: Int): ServerBuilder<*> =
        NettyServerBuilder.forPort(port)
            .maxInboundMessageSize(64 * 1024 * 1024)

    override fun newServerBuilderForPort(
        port: Int,
        credentials: ServerCredentials,
    ): NewServerBuilderResult =
        try {
            NewServerBuilderResult.serverBuilder(
                NettyServerBuilder.forPort(port, credentials)
                    .maxInboundMessageSize(64 * 1024 * 1024),
            )
        } catch (e: IllegalArgumentException) {
            NewServerBuilderResult.error(e.message ?: "Unsupported ServerCredentials")
        }
}
Downside: this is process-wide for every
ServerBuilder.forPort
/
newServerBuilderForPort
in the JVM, not just the kotlinx-rpc servers. Happy to switch to
GrpcServer { maxInboundMessageSize = … }
as soon as that’s released.
a
Hi! Yes, the mentioned PR is exactly for that, I didn't yet had time to look into it, but I'll try to prioritoze it
gratitude thank you 1
kodee welcoming 2