Merge pull request #7715 from bshramin/http-client-timeout
lntest: set ReadHeaderTimeout for http client
This commit is contained in:
6 files changed
+33
-14
No files matched your search
@@ -226,6 +226,9 @@ const (
|
|||||||
// client should wait before sending a keepalive ping.
|
// client should wait before sending a keepalive ping.
|
||||||
defaultGrpcClientPingMinWait = 5 * time.Second
|
defaultGrpcClientPingMinWait = 5 * time.Second
|
||||||
|
|
||||||
|
// defaultHTTPHeaderTimeout is the default timeout for HTTP requests.
|
||||||
|
DefaultHTTPHeaderTimeout = 5 * time.Second
|
||||||
|
|
||||||
// BitcoinChainName is a string that represents the Bitcoin blockchain.
|
// BitcoinChainName is a string that represents the Bitcoin blockchain.
|
||||||
BitcoinChainName = "bitcoin"
|
BitcoinChainName = "bitcoin"
|
||||||
|
|
||||||
@@ -492,6 +495,10 @@ type Config struct {
|
|||||||
// Dev specifies configs used for integration tests, which is always
|
// Dev specifies configs used for integration tests, which is always
|
||||||
// empty if not built with `integration` flag.
|
// empty if not built with `integration` flag.
|
||||||
Dev *lncfg.DevConfig `group:"dev" namespace:"dev"`
|
Dev *lncfg.DevConfig `group:"dev" namespace:"dev"`
|
||||||
|
|
||||||
|
// HTTPHeaderTimeout is the maximum duration that the server will wait
|
||||||
|
// before timing out reading the headers of an HTTP request.
|
||||||
|
HTTPHeaderTimeout time.Duration `long:"http-header-timeout" description:"The maximum duration that the server will wait before timing out reading the headers of an HTTP request."`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GRPCConfig holds the configuration options for the gRPC server.
|
// GRPCConfig holds the configuration options for the gRPC server.
|
||||||
@@ -694,7 +701,8 @@ func DefaultConfig() Config {
|
|||||||
ServerPingTimeout: defaultGrpcServerPingTimeout,
|
ServerPingTimeout: defaultGrpcServerPingTimeout,
|
||||||
ClientPingMinWait: defaultGrpcClientPingMinWait,
|
ClientPingMinWait: defaultGrpcClientPingMinWait,
|
||||||
},
|
},
|
||||||
WtClient: lncfg.DefaultWtClientCfg(),
|
WtClient: lncfg.DefaultWtClientCfg(),
|
||||||
|
HTTPHeaderTimeout: DefaultHTTPHeaderTimeout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,16 @@
|
|||||||
- [Functional Updates](#functional-updates)
|
- [Functional Updates](#functional-updates)
|
||||||
- [RPC Updates](#rpc-updates)
|
- [RPC Updates](#rpc-updates)
|
||||||
- [lncli Updates](#lncli-updates)
|
- [lncli Updates](#lncli-updates)
|
||||||
|
- [Code Health](#code-health)
|
||||||
- [Breaking Changes](#breaking-changes)
|
- [Breaking Changes](#breaking-changes)
|
||||||
- [Performance Improvements](#performance-improvements)
|
- [Performance Improvements](#performance-improvements)
|
||||||
- [Technical and Architectural Updates](#technical-and-architectural-updates)
|
- [Technical and Architectural Updates](#technical-and-architectural-updates)
|
||||||
- [BOLT Spec Updates](#bolt-spec-updates)
|
- [BOLT Spec Updates](#bolt-spec-updates)
|
||||||
- [Testing](#testing)
|
- [Testing](#testing)
|
||||||
- [Database](#database)
|
- [Database](#database)
|
||||||
- [Code Health](#code-health)
|
- [Code Health](#code-health-1)
|
||||||
- [Tooling and Documentation](#tooling-and-documentation)
|
- [Tooling and Documentation](#tooling-and-documentation)
|
||||||
|
- [Contributors (Alphabetical Order)](#contributors-alphabetical-order)
|
||||||
|
|
||||||
# Bug Fixes
|
# Bug Fixes
|
||||||
|
|
||||||
@@ -40,6 +42,8 @@
|
|||||||
and payment to blinded paths has been added via the `QueryRoutes` (and
|
and payment to blinded paths has been added via the `QueryRoutes` (and
|
||||||
SendToRouteV2) APIs. This functionality is surfaced in `lncli queryroutes`
|
SendToRouteV2) APIs. This functionality is surfaced in `lncli queryroutes`
|
||||||
where the required flags are tagged with `(blinded paths)`.
|
where the required flags are tagged with `(blinded paths)`.
|
||||||
|
* A new config value,
|
||||||
|
[http-header-timeout](https://github.com/lightningnetwork/lnd/pull/7715), is added so users can specify the amount of time the http server will wait for a request to complete before closing the connection. The default value is 5 seconds.
|
||||||
|
|
||||||
## RPC Additions
|
## RPC Additions
|
||||||
## lncli Additions
|
## lncli Additions
|
||||||
@@ -83,6 +87,7 @@
|
|||||||
|
|
||||||
# Contributors (Alphabetical Order)
|
# Contributors (Alphabetical Order)
|
||||||
|
|
||||||
|
* Amin Bashiri
|
||||||
* Andras Banki-Horvath
|
* Andras Banki-Horvath
|
||||||
* Carla Kirk-Cohen
|
* Carla Kirk-Cohen
|
||||||
* Elle Mouton
|
* Elle Mouton
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
|
|||||||
pprofServer := &http.Server{
|
pprofServer := &http.Server{
|
||||||
Addr: cfg.Profile,
|
Addr: cfg.Profile,
|
||||||
Handler: pprofMux,
|
Handler: pprofMux,
|
||||||
ReadHeaderTimeout: 5 * time.Second,
|
ReadHeaderTimeout: cfg.HTTPHeaderTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shut the server down when lnd is shutting down.
|
// Shut the server down when lnd is shutting down.
|
||||||
@@ -271,6 +271,8 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
|
|||||||
LetsEncryptListen: cfg.LetsEncryptListen,
|
LetsEncryptListen: cfg.LetsEncryptListen,
|
||||||
|
|
||||||
DisableRestTLS: cfg.DisableRestTLS,
|
DisableRestTLS: cfg.DisableRestTLS,
|
||||||
|
|
||||||
|
HTTPHeaderTimeout: cfg.HTTPHeaderTimeout,
|
||||||
}
|
}
|
||||||
tlsManager := NewTLSManager(tlsManagerCfg)
|
tlsManager := NewTLSManager(tlsManagerCfg)
|
||||||
serverOpts, restDialOpts, restListen, cleanUp,
|
serverOpts, restDialOpts, restListen, cleanUp,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/lightningnetwork/lnd"
|
||||||
"github.com/lightningnetwork/lnd/lntest/node"
|
"github.com/lightningnetwork/lnd/lntest/node"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
@@ -81,8 +82,9 @@ func NewFeeService(t *testing.T) *FeeService {
|
|||||||
mux.HandleFunc("/fee-estimates.json", f.handleRequest)
|
mux.HandleFunc("/fee-estimates.json", f.handleRequest)
|
||||||
|
|
||||||
f.srv = &http.Server{
|
f.srv = &http.Server{
|
||||||
Addr: listenAddr,
|
Addr: listenAddr,
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
|
ReadHeaderTimeout: lnd.DefaultHTTPHeaderTimeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &f
|
return &f
|
||||||
|
|||||||
@@ -519,6 +519,9 @@
|
|||||||
; intelligence services.
|
; intelligence services.
|
||||||
; color=#3399FF
|
; color=#3399FF
|
||||||
|
|
||||||
|
; The maximum duration that the server will wait before timing out reading
|
||||||
|
; the headers of an HTTP request.
|
||||||
|
; http-header-timeout=5s
|
||||||
|
|
||||||
[prometheus]
|
[prometheus]
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -39,9 +39,6 @@ var (
|
|||||||
// - `-----BEGIN PRIVATE KEY-----` (PKCS8).
|
// - `-----BEGIN PRIVATE KEY-----` (PKCS8).
|
||||||
// - `-----BEGIN EC PRIVATE KEY-----` (SEC1/rfc5915, the legacy format).
|
// - `-----BEGIN EC PRIVATE KEY-----` (SEC1/rfc5915, the legacy format).
|
||||||
privateKeyPrefix = []byte("-----BEGIN ")
|
privateKeyPrefix = []byte("-----BEGIN ")
|
||||||
|
|
||||||
// letsEncryptTimeout sets a timeout for the Lets Encrypt server.
|
|
||||||
letsEncryptTimeout = 5 * time.Second
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TLSManagerCfg houses a set of values and methods that is passed to the
|
// TLSManagerCfg houses a set of values and methods that is passed to the
|
||||||
@@ -61,6 +58,8 @@ type TLSManagerCfg struct {
|
|||||||
LetsEncryptListen string
|
LetsEncryptListen string
|
||||||
|
|
||||||
DisableRestTLS bool
|
DisableRestTLS bool
|
||||||
|
|
||||||
|
HTTPHeaderTimeout time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// TLSManager generates/renews a TLS cert/key pair when needed. When required,
|
// TLSManager generates/renews a TLS cert/key pair when needed. When required,
|
||||||
@@ -424,7 +423,7 @@ func (t *TLSManager) setUpLetsEncrypt(certData *tls.Certificate,
|
|||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Addr: t.cfg.LetsEncryptListen,
|
Addr: t.cfg.LetsEncryptListen,
|
||||||
Handler: manager.HTTPHandler(nil),
|
Handler: manager.HTTPHandler(nil),
|
||||||
ReadHeaderTimeout: letsEncryptTimeout,
|
ReadHeaderTimeout: t.cfg.HTTPHeaderTimeout,
|
||||||
}
|
}
|
||||||
shutdownCompleted := make(chan struct{})
|
shutdownCompleted := make(chan struct{})
|
||||||
cleanUp = func() {
|
cleanUp = func() {
|
||||||
|
|||||||
Reference in new issue
Block a user