Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: HTTP/2 retry loop broken when net/http manages dials #52459

Open
neild opened this issue Apr 21, 2022 · 1 comment
Open

net/http: HTTP/2 retry loop broken when net/http manages dials #52459

neild opened this issue Apr 21, 2022 · 1 comment
Assignees
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@neild
Copy link
Contributor

neild commented Apr 21, 2022

http2.Transport.RoundTripOpt retries requests under some circumstances (transport.go#492):

for retry := 0; ; retry++ {
  cc, err := t.connPool().GetClientConn(req, addr)
   if err != nil {
    t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err)
    return nil, err
  }
  // ...

When using the bundled HTTP/2 support in net/http, however, GetClientConn does not dial connections when none are available. Instead, it returns ErrNoCachedConn and net/http handles the dial.

This results in an infinite retry loop when the server immediately hangs up on a retryable request.

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 22, 2022
@thanm thanm added this to the Backlog milestone Apr 22, 2022
@neild neild self-assigned this Apr 25, 2022
@WGH-
Copy link

WGH- commented May 30, 2023

I can easily reproduce this with nginx special return code 444 ("close connection"):

location /nginx-444 {
    return 444;
}
package main

import (
	"log"
	"net/http"
)

func main() {
	resp, err := http.Get("https://chireiden.torlan.ru/nginx-444")
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()
	log.Printf("%s", resp.Status)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants