Skip to content

Commit 2e3cb14

Browse files
Merge pull request #939 from lightninglabs/docs-taproot-assets
Update taproot-assets documentation
2 parents 2e5c5bc + f86708a commit 2e3cb14

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

docs/taproot-assets/examples/basic-price-oracle/main.go

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/sirupsen/logrus"
3030
"google.golang.org/grpc"
3131
"google.golang.org/grpc/credentials"
32+
"google.golang.org/grpc/keepalive"
3233
)
3334

3435
const (
@@ -455,11 +456,44 @@ func main() {
455456
log.Fatalf("Failed to generate TLS certificate: %v", err)
456457
}
457458

458-
// Create the gRPC server with TLS
459+
// Configure server-side keepalive parameters. These settings ensure the
460+
// server actively probes client connection health and allows long-lived
461+
// idle connections.
462+
serverKeepalive := keepalive.ServerParameters{
463+
// Ping clients after 1 minute of inactivity.
464+
Time: time.Minute,
465+
466+
// Wait 20 seconds for ping response.
467+
Timeout: 20 * time.Second,
468+
469+
// Allow connections to stay idle for 24 hours. The active
470+
// pinging mechanism (via Time parameter) handles health
471+
// checking, so we don't need aggressive idle timeouts.
472+
MaxConnectionIdle: time.Hour * 24,
473+
}
474+
475+
// Configure client keepalive enforcement policy. This tells the server
476+
// how to handle client keepalive pings.
477+
clientKeepalive := keepalive.EnforcementPolicy{
478+
// Allow client to ping even when there are no active RPCs.
479+
// This is critical for long-lived connections with infrequent
480+
// price queries.
481+
PermitWithoutStream: true,
482+
483+
// Prevent abusive clients from pinging too frequently (DoS
484+
// protection).
485+
MinTime: 5 * time.Second,
486+
}
487+
488+
// Create the gRPC server with TLS and keepalive configuration.
459489
transportCredentials := credentials.NewTLS(&tls.Config{
460490
Certificates: []tls.Certificate{tlsCert},
461491
})
462-
backendService := grpc.NewServer(grpc.Creds(transportCredentials))
492+
backendService := grpc.NewServer(
493+
grpc.Creds(transportCredentials),
494+
grpc.KeepaliveParams(serverKeepalive),
495+
grpc.KeepaliveEnforcementPolicy(clientKeepalive),
496+
)
463497

464498
err = startService(backendService)
465499
if err != nil {

docs/taproot-assets/release-notes/release-notes-0.7.0.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@
6363
dirty. This issue has been resolved, and the behavior is now consistent across
6464
all database backend types.
6565

66+
- [Fixed "connection reset by peer" errors in RFQ price oracle
67+
connections](https://github.com/lightninglabs/taproot-assets/pull/1834) by
68+
implementing comprehensive bidirectional gRPC keepalive configuration. The
69+
issue occurred when connections sat idle between RFQ price queries and were
70+
silently closed by the network layer or server timeout, causing the first
71+
payment attempt after an idle period to fail. The fix adds client-side
72+
keepalive pings every 30 seconds and extends the server's idle connection
73+
timeout from 2 minutes to 24 hours, while enabling active health checking on
74+
both sides. This ensures connections remain alive during infrequent RFQ
75+
operations and any network issues are detected promptly rather than
76+
discovered only when the next RPC fails.
77+
6678
# New Features
6779

6880
## Functional Enhancements

0 commit comments

Comments
 (0)