Skip to content

Commit

Permalink
http2: log pings and RoundTrip retries when http2debug=1
Browse files Browse the repository at this point in the history
Change-Id: I3a7358db65ebc474712817a776d8468d0b09f0ab
Reviewed-on: https://go-review.googlesource.com/c/net/+/359914
Trust: Damien Neil <[email protected]>
Run-TryBot: Damien Neil <[email protected]>
Trust: Brad Fitzpatrick <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
neild committed Apr 1, 2022
1 parent de3da57 commit 543a649
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion http2/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,14 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res
if req, err = shouldRetryRequest(req, err); err == nil {
// After the first retry, do exponential backoff with 10% jitter.
if retry == 0 {
t.vlogf("RoundTrip retrying after failure: %v", err)
continue
}
backoff := float64(uint(1) << (uint(retry) - 1))
backoff += backoff * (0.1 * mathrand.Float64())
select {
case <-time.After(time.Second * time.Duration(backoff)):
t.vlogf("RoundTrip retrying after failure: %v", err)
continue
case <-req.Context().Done():
err = req.Context().Err()
Expand Down Expand Up @@ -732,10 +734,13 @@ func (cc *ClientConn) healthCheck() {
// trigger the healthCheck again if there is no frame received.
ctx, cancel := context.WithTimeout(context.Background(), pingTimeout)
defer cancel()
cc.vlogf("http2: Transport sending health check")
err := cc.Ping(ctx)
if err != nil {
cc.vlogf("http2: Transport health check failure: %v", err)
cc.closeForLostPing()
return
} else {
cc.vlogf("http2: Transport health check success")
}
}

Expand Down

0 comments on commit 543a649

Please sign in to comment.