mirror of
https://github.com/octoleo/restic.git
synced 2024-12-18 16:42:00 +00:00
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
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/peterbourgon/unixtransport"
|
"github.com/peterbourgon/unixtransport"
|
||||||
"github.com/restic/restic/internal/debug"
|
"github.com/restic/restic/internal/debug"
|
||||||
"github.com/restic/restic/internal/errors"
|
"github.com/restic/restic/internal/errors"
|
||||||
|
"golang.org/x/net/http2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TransportOptions collects various options which can be set for an HTTP based
|
// 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,
|
KeepAlive: 30 * time.Second,
|
||||||
DualStack: true,
|
DualStack: true,
|
||||||
}).DialContext,
|
}).DialContext,
|
||||||
ForceAttemptHTTP2: true,
|
|
||||||
MaxIdleConns: 100,
|
MaxIdleConns: 100,
|
||||||
MaxIdleConnsPerHost: 100,
|
MaxIdleConnsPerHost: 100,
|
||||||
IdleConnTimeout: 90 * time.Second,
|
IdleConnTimeout: 90 * time.Second,
|
||||||
@ -83,6 +83,17 @@ func Transport(opts TransportOptions) (http.RoundTripper, error) {
|
|||||||
TLSClientConfig: &tls.Config{},
|
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)
|
unixtransport.Register(tr)
|
||||||
|
|
||||||
if opts.InsecureTLS {
|
if opts.InsecureTLS {
|
||||||
|
Loading…
Reference in New Issue
Block a user