mirror of
https://github.com/aljazceru/lspd.git
synced 2026-02-08 15:54:23 +01:00
add keepalive settings for cln client/server
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
@@ -45,7 +46,15 @@ func NewClnHtlcInterceptor() *ClnHtlcInterceptor {
|
||||
func (i *ClnHtlcInterceptor) Start() error {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
log.Printf("Dialing cln plugin on '%s'", i.pluginAddress)
|
||||
conn, err := grpc.DialContext(ctx, i.pluginAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
conn, err := grpc.DialContext(
|
||||
ctx,
|
||||
i.pluginAddress,
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithKeepaliveParams(keepalive.ClientParameters{
|
||||
Time: time.Duration(10) * time.Second,
|
||||
Timeout: time.Duration(10) * time.Second,
|
||||
}),
|
||||
)
|
||||
if err != nil {
|
||||
log.Printf("grpc.Dial error: %v", err)
|
||||
cancel()
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/breez/lspd/cln_plugin/proto"
|
||||
grpc "google.golang.org/grpc"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
)
|
||||
|
||||
// Internal htlc_accepted message meant for the sendQueue.
|
||||
@@ -76,7 +77,15 @@ func (s *server) Start() error {
|
||||
|
||||
s.done = make(chan struct{})
|
||||
s.newSubscriber = make(chan struct{})
|
||||
s.grpcServer = grpc.NewServer()
|
||||
s.grpcServer = grpc.NewServer(
|
||||
grpc.KeepaliveParams(keepalive.ServerParameters{
|
||||
Time: time.Duration(1) * time.Second,
|
||||
Timeout: time.Duration(10) * time.Second,
|
||||
}),
|
||||
grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
|
||||
MinTime: time.Duration(1) * time.Second,
|
||||
}),
|
||||
)
|
||||
s.mtx.Unlock()
|
||||
proto.RegisterClnPluginServer(s.grpcServer, s)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user