func configureHttp2TransportPing()

in pkg/middleware/default_http_client.go [78:93]


func configureHttp2TransportPing(tr *http.Transport) {
	// http2Transport holds a reference to the default transport and configures "h2" middlewares that
	// will use the below settings, making the standard http.Transport behave correctly for dropped connections
	http2Transport, err := http2.ConfigureTransports(tr)
	if err != nil {
		// by initializing in init(), we know it is only called once.
		// this errors if called twice.
		panic(err)
	}
	// we give 10s to the server to respond to the ping. if no response is received,
	// the transport will close the connection, so that the next request will open a new connection, and not
	// hit a context deadline exceeded error.
	http2Transport.PingTimeout = 10 * time.Second
	// if no frame is received for 30s, the transport will issue a ping health check to the server.
	http2Transport.ReadIdleTimeout = 30 * time.Second
}