From 4ccc703cab1dc6d36c4d1af4313058513b45734a Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 5 Jun 2023 11:01:33 +0200 Subject: [PATCH 1/2] server: specify gRPC keepalive params With this commit we instruct the gRPC client to ping the server every 10 seconds to make sure the TCP connection is still alive. --- server.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/server.go b/server.go index a081e02..f774e12 100644 --- a/server.go +++ b/server.go @@ -13,6 +13,7 @@ import ( "strings" "sync" "sync/atomic" + "time" "github.com/btcsuite/btcd/btcec/v2" proxy "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" @@ -34,6 +35,7 @@ import ( "github.com/lightningnetwork/lnd/macaroons" "github.com/lightningnetwork/lnd/signal" "google.golang.org/grpc" + "google.golang.org/grpc/keepalive" "google.golang.org/grpc/metadata" "google.golang.org/protobuf/encoding/protojson" "gopkg.in/macaroon-bakery.v2/bakery" @@ -68,6 +70,12 @@ var ( "signrpc", "walletrpc", "chainrpc", "invoicesrpc", }, } + + // defaultClientPingTime is the default time we'll use for the client + // keepalive ping time. This means the client will ping the server every + // 10 seconds (if there is no other activity) to make sure the TCP + // connection is still alive. + defaultClientPingTime = 10 * time.Second ) // Server is the main poold trader server. @@ -562,6 +570,20 @@ func (s *Server) setupClient() error { ), ) + // For non-regtest networks we also want to turn on gRPC keepalive to + // detect stale connections. We don't do this for regtest because there + // might be older regtest-only servers out there where this would lead + // to disconnects because the server doesn't allow pings that often + // (since this requires a server side change to be deployed as well). + if s.cfg.Network != "regtest" { + s.cfg.AuctioneerDialOpts = append( + s.cfg.AuctioneerDialOpts, + grpc.WithKeepaliveParams(keepalive.ClientParameters{ + Time: defaultClientPingTime, + }), + ) + } + // Create the funding manager. The RPC server is responsible for // starting/stopping it though as all that logic is currently there for // the other managers as well. From 820b4e470dcb4e6c220903af54cef4133921f219 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Mon, 5 Jun 2023 18:05:30 +0200 Subject: [PATCH 2/2] version: bump to v0.6.4-beta --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index 7d893cb..bc8009f 100644 --- a/version.go +++ b/version.go @@ -29,7 +29,7 @@ const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr const ( appMajor uint = 0 appMinor uint = 6 - appPatch uint = 3 + appPatch uint = 4 // appPreRelease MUST only contain characters from semanticAlphabet per // the semantic versioning spec.