forked from TrueCloudLab/restic
backend: configure protocol-level connection health checks
This should detect a connection that is stuck for more than 2 minutes.
This commit is contained in:
parent
24c1822220
commit
0987c731ec
1 changed files with 12 additions and 1 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/peterbourgon/unixtransport"
|
||||
"github.com/restic/restic/internal/debug"
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"golang.org/x/net/http2"
|
||||
)
|
||||
|
||||
// TransportOptions collects various options which can be set for an HTTP based
|
||||
|
@ -74,7 +75,6 @@ func Transport(opts TransportOptions) (http.RoundTripper, error) {
|
|||
KeepAlive: 30 * time.Second,
|
||||
DualStack: true,
|
||||
}).DialContext,
|
||||
ForceAttemptHTTP2: true,
|
||||
MaxIdleConns: 100,
|
||||
MaxIdleConnsPerHost: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
|
@ -83,6 +83,17 @@ func Transport(opts TransportOptions) (http.RoundTripper, error) {
|
|||
TLSClientConfig: &tls.Config{},
|
||||
}
|
||||
|
||||
// ensure that http2 connections are closed if they are broken
|
||||
h2, err := http2.ConfigureTransports(tr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if feature.Flag.Enabled(feature.HTTPTimeouts) {
|
||||
h2.WriteByteTimeout = 120 * time.Second
|
||||
h2.ReadIdleTimeout = 60 * time.Second
|
||||
h2.PingTimeout = 60 * time.Second
|
||||
}
|
||||
|
||||
unixtransport.Register(tr)
|
||||
|
||||
if opts.InsecureTLS {
|
||||
|
|
Loading…
Reference in a new issue