diff --git a/lnwallet/rpcwallet/healthcheck.go b/lnwallet/rpcwallet/healthcheck.go index 27bcb9c73..7a412959e 100644 --- a/lnwallet/rpcwallet/healthcheck.go +++ b/lnwallet/rpcwallet/healthcheck.go @@ -11,7 +11,7 @@ import ( // configuration. func HealthCheck(cfg *lncfg.RemoteSigner, timeout time.Duration) func() error { return func() error { - _, err := connectRPC( + conn, err := connectRPC( cfg.RPCHost, cfg.TLSCertPath, cfg.MacaroonPath, timeout, ) if err != nil { @@ -19,6 +19,15 @@ func HealthCheck(cfg *lncfg.RemoteSigner, timeout time.Duration) func() error { "signing node through RPC: %v", err) } + defer func() { + err = conn.Close() + if err != nil { + log.Warnf("Failed to close health check "+ + "connection to remote signing node: %v", + err) + } + }() + return nil } }