From 0ffc3e9664b88b7506a7c99cb4dd8b0bf1a92f2c Mon Sep 17 00:00:00 2001 From: Gabe Ruttner Date: Wed, 15 May 2024 06:31:04 -0700 Subject: [PATCH] fix: keep alive enforcement policy (#499) * fix: keep alive enforcement policy * fix: half min --- internal/services/grpc/server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/services/grpc/server.go b/internal/services/grpc/server.go index 36c546878..871dc13cd 100644 --- a/internal/services/grpc/server.go +++ b/internal/services/grpc/server.go @@ -245,6 +245,13 @@ func (s *Server) startGRPC() (func() error, error) { recovery.UnaryServerInterceptor(recovery.WithRecoveryHandler(grpcPanicRecoveryHandler)), )) + var enforcement = keepalive.EnforcementPolicy{ + MinTime: 5 * time.Second, + PermitWithoutStream: true, + } + + serverOpts = append(serverOpts, grpc.KeepaliveEnforcementPolicy(enforcement)) + var kasp = keepalive.ServerParameters{ // ping the client every 30 seconds if idle to ensure the connection is still active Time: 30 * time.Second,