-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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: check connection from pool before use #51202
Comments
Sorry to ask, is anyone following this question? @dmitshur |
There is failover looking for a good connection. Lines 1032 to 1080 in 851ecea
Kindly cc owner @bradfitz |
There are two cases in which the link in the link pool is closed. One is that the client actively closes the link, and the other is that the server closes the link due to the timeout of the link idle time. The problem is in the second case.
Through observation and monitoring, the probability of the above two problems occurring is one in a million. |
The code looks like this:
|
CC @neild |
What version of Go are you using (
go version
)?go1.16.3 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/laozhang/Library/Caches/go-build"
GOENV="/Users/laozhang/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/laozhang/go/pkg/mod"
GONOPROXY="git.code.oa.com"
GONOSUMDB="git.code.oa.com,git.code.woa.com"
GOOS="darwin"
GOPATH="/Users/laozhang/go"
GOPRIVATE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pg/7d_r_s8j6v362rgv9nqkrsbh0000gn/T/go-build3091927261=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
I used "net/http/httputil/reverseproxy.go" to build a http proxy, but it often happens: Request forwarding failed with error "EOF". It should be because: after the link is taken out from the link pool, the peer end closes the link when the proxy sends the request, causing the proxy to report an "EOF" error when it reads the response. Because it is a POST request, retrying may cause other unexpected errors.
Can an optimization be done here? After removing the link from the link pool, do a health check before using it. For example, if you try to read a byte from the link, the theoretical result should be: neither data can be read nor an error reported; any other result means that The currently fetched link is unavailable and should be discarded.
What did you expect to see?
has already been said above.
What did you see instead?
has already been said above.
The text was updated successfully, but these errors were encountered: