Add keep-alive to grpc server (fixes clients ws cancellation when no data passed) (#468)
This commit is contained in:
@@ -26,5 +26,9 @@ class Defaults {
|
||||
val timeout: Duration = Duration.ofSeconds(60)
|
||||
val timeoutInternal: Duration = timeout.dividedBy(4)
|
||||
val retryConnection: Duration = Duration.ofSeconds(10)
|
||||
val grpcServerKeepAliveTime: Long = 15 // seconds
|
||||
val grpcServerKeepAliveTimeout: Long = 5
|
||||
val grpcServerPermitKeepAliveTime: Long = 15
|
||||
val grpcServerMaxConnectionIdle: Long = 3600
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.scheduling.concurrent.CustomizableThreadFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import java.net.InetSocketAddress
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.annotation.PostConstruct
|
||||
import javax.annotation.PreDestroy
|
||||
|
||||
@@ -74,6 +75,11 @@ open class GrpcServer(
|
||||
.forAddress(InetSocketAddress(mainConfig.host, mainConfig.port))
|
||||
.maxInboundMessageSize(Defaults.maxMessageSize)
|
||||
.maxInboundMetadataSize(maxMetadataSize)
|
||||
.keepAliveTime(Defaults.grpcServerKeepAliveTime, TimeUnit.SECONDS)
|
||||
.keepAliveTimeout(Defaults.grpcServerKeepAliveTimeout, TimeUnit.SECONDS)
|
||||
.permitKeepAliveTime(Defaults.grpcServerPermitKeepAliveTime, TimeUnit.SECONDS)
|
||||
.permitKeepAliveWithoutCalls(true)
|
||||
.maxConnectionIdle(Defaults.grpcServerMaxConnectionIdle, TimeUnit.SECONDS)
|
||||
|
||||
if (mainConfig.accessLogConfig.enabled) {
|
||||
serverBuilder.intercept(accessHandler)
|
||||
|
||||
Reference in New Issue
Block a user