Skip to content

Commit

Permalink
Add TCP Idle TimeOut sideshow#24
Browse files Browse the repository at this point in the history
  • Loading branch information
terry-xiaoyu committed Jan 23, 2018
1 parent df275e5 commit 23bd2b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ var (
// TCPKeepAlive specifies the keep-alive period for an active network
// connection. If zero, keep-alives are not enabled.
TCPKeepAlive = 60 * time.Second

// TCPIdleTimeOut is the maximum amount of time an idle
// (keep-alive) connection will remain idle before closing
// itself.
// Zero means no limit.
TCPIdleTimeOut = 0 * time.Second
)

// DialTLS is the default dial function for creating TLS connections for
Expand Down Expand Up @@ -82,6 +88,7 @@ func NewClient(certificate tls.Certificate) *Client {
transport := &http2.Transport{
TLSClientConfig: tlsConfig,
DialTLS: DialTLS,
IdleConnTimeout: TCPIdleTimeOut,
}
return &Client{
HTTPClient: &http.Client{
Expand Down
8 changes: 7 additions & 1 deletion vendor/golang.org/x/net/http2/transport.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 23bd2b6

Please sign in to comment.