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/httputil: ReverseProxy produces the error context canceled on high load #34813

Closed
strive1216 opened this issue Oct 10, 2019 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@strive1216
Copy link

strive1216 commented Oct 10, 2019

What version of Go are you using (go version)?

go version go1.13.1 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
GO111MODULE="on"
GOARCH="amd64"
GOBIN="/home/zl/Desktop/mywork/GO/test01/bin"
GOCACHE="/home/zl/.cache/go-build"
GOENV="/home/zl/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zl/Desktop/mywork/GO/test01"
GOPRIVATE=""
GOPROXY="https://goproxy.cn"
GOROOT="/home/zl/opt/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/zl/opt/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build605714083=/tmp/go-build -gno-record-gcc-switches"

What did you do?

func proxy(proxy *httputil.ReverseProxy, c *gin.Context) {
	logger := log.New(os.Stderr, "", log.LstdFlags|log.Llongfile)
	proxy.ErrorLog = logger
	proxy.ErrorHandler = func(writer http.ResponseWriter, request *http.Request, e error) {
		logger.Printf("%v %v\n", request.URL.Path, e.Error()) --> context canceled
	}
	proxy.Transport = &http.Transport{
		DialContext: (&net.Dialer{
			Timeout:       90 * time.Second,
			KeepAlive:     90 * time.Second,
			FallbackDelay: -1 * time.Second,
		}).DialContext,
		ForceAttemptHTTP2:     false,
		MaxIdleConns:          100,
		IdleConnTimeout:       1 * time.Second,
		TLSHandshakeTimeout:   10 * time.Second,
		ExpectContinueTimeout: 1 * time.Second,
	}
	proxy.ServeHTTP(c.Writer, c.Request)
}

What did you see instead?

High concurrency exception:
logger.Printf("%v %v\n", request.URL.Path, e.Error()) --> context canceled

@andybons
Copy link
Member

What is a "high-concurrency exception"?

@andybons andybons added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 10, 2019
@andybons andybons added this to the Unplanned milestone Oct 10, 2019
@strive1216
Copy link
Author

2w QPS touch off “context canceled”

@odeke-em
Copy link
Member

@Refuel-ZL thank you for filing this issue and welcome to the Go project!

2w QPS touch off “context canceled”

What does that "2w" "touch off" mean? Could you please be more specific and also it would be nice if you could try to simulate/reproduce this issue for example using http://github.com/rakyll/hey or Apache bench or whichever load generator you'd like? Thank you!

@odeke-em odeke-em changed the title httputil.ReverseProxy The error context canceled net/http/httputil: ReverseProxy produces the error context canceled on high load Oct 11, 2019
@mvdan
Copy link
Member

mvdan commented Jun 15, 2021

Closing old issues that still have the WaitingForInfo label where enough details to investigate weren't provided. Feel free to leave a comment with more details and we can reopen.

@mvdan mvdan closed this as completed Jun 15, 2021
@golang golang locked and limited conversation to collaborators Jun 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants