diff --git a/server.go b/server.go index fd69e1558..da1bba94c 100644 --- a/server.go +++ b/server.go @@ -7,6 +7,7 @@ import ( "strings" "sync" "sync/atomic" + "time" proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/lightninglabs/lndclient" @@ -21,6 +22,7 @@ import ( "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/macaroons" "google.golang.org/grpc" + "google.golang.org/grpc/keepalive" "gopkg.in/macaroon-bakery.v2/bakery" ) @@ -269,6 +271,12 @@ func (s *Server) RunUntilShutdown(mainErrChan <-chan error) error { serverOpts = append(serverOpts, rpcServerOpts...) serverOpts = append(serverOpts, ServerMaxMsgReceiveSize) + keepAliveParams := keepalive.ServerParameters{ + MaxConnectionIdle: time.Minute * 2, + } + + serverOpts = append(serverOpts, grpc.KeepaliveParams(keepAliveParams)) + grpcServer := grpc.NewServer(serverOpts...) defer grpcServer.Stop() diff --git a/universe/syncer.go b/universe/syncer.go index 6d65a716d..cff1894f2 100644 --- a/universe/syncer.go +++ b/universe/syncer.go @@ -461,7 +461,6 @@ func (s *SimpleSyncer) SyncUniverse(ctx context.Context, host ServerAddr, return nil, fmt.Errorf("unable to create remote diff "+ "engine: %w", err) } - defer diffEngine.Close() // With the engine created, we can now sync the local Universe with the