From a55bd2305f6aa7925fceb05c3582f5306c139cd0 Mon Sep 17 00:00:00 2001 From: Maksim Fomenkov Date: Wed, 30 Nov 2022 18:03:31 +0400 Subject: [PATCH] imcrease gRPC message size limit --- .../dshackle/upstream/grpc/GrpcUpstreams.kt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/GrpcUpstreams.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/GrpcUpstreams.kt index e49a38d6..588d5fdd 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/GrpcUpstreams.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/grpc/GrpcUpstreams.kt @@ -29,7 +29,6 @@ import io.emeraldpay.dshackle.upstream.DefaultUpstream import io.emeraldpay.dshackle.upstream.UpstreamAvailability import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcGrpcClient import io.emeraldpay.dshackle.upstream.rpcclient.RpcMetrics -import io.grpc.ManagedChannelBuilder import io.grpc.netty.NettyChannelBuilder import io.micrometer.core.instrument.Counter import io.micrometer.core.instrument.Metrics @@ -70,21 +69,21 @@ class GrpcUpstreams( private val lock = ReentrantLock() fun start(): Flux { - val channel: ManagedChannelBuilder<*> = if (auth != null && StringUtils.isNotEmpty(auth.ca)) { - NettyChannelBuilder.forAddress(host, port) - // some messages are very large. many of them in megabytes, some even in gigabytes (ex. ETH Traces) - .maxInboundMessageSize(Int.MAX_VALUE) + val chanelBuilder = NettyChannelBuilder.forAddress(host, port) + // some messages are very large. many of them in megabytes, some even in gigabytes (ex. ETH Traces) + .maxInboundMessageSize(Int.MAX_VALUE) + .enableRetry() + .maxRetryAttempts(3) + if (auth != null && StringUtils.isNotEmpty(auth.ca)) { + chanelBuilder .useTransportSecurity() - .enableRetry() - .maxRetryAttempts(3) .sslContext(withTls(auth)) } else { log.warn("Using insecure connection to $host:$port") - ManagedChannelBuilder.forAddress(host, port) - .usePlaintext() + chanelBuilder.usePlaintext() } - val client = ReactorBlockchainGrpc.newReactorStub(channel.build()) + val client = ReactorBlockchainGrpc.newReactorStub(chanelBuilder.build()) this.client = client val statusSubscription = AtomicReference()