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

question: net/http: why does a server not drop client connection after write timeout? #31463

Closed
riandyrn opened this issue Apr 15, 2019 · 1 comment

Comments

@riandyrn
Copy link

Please answer these questions before submitting your issue. Thanks!

What did you do?

https://play.golang.org/p/HvJuH020rlN

I was setting the Server.WriteTimeout to 1 second while I set the handler to run for 10 seconds to simulate long running load. Then execute client to access the server.

What did you expect to see?

I was expecting the client would return after 1 second, because I thought Server.WriteTimeout is used to limit client connection duration, like mentioned in here: https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts#servertimeouts.

What did you see instead?

The client return after 10 seconds. This means even after Server.WriteTimeout is exceeded, the client connection still holds up until handler return the response (though the response would not be retrieved by client, since it is counted as error).

Is this the expected behavior? If so, what is the usage of Server.WriteTimeout actually?

Or perhaps I'm just using it wrong?

Related issues: #24461, #21389 => both of them just discussing about the behavior of ResponseWriter.Write() but not related to overall duration of the request.

Thanks

System details

go version go1.12.4 darwin/amd64
GOARCH="amd64"
GOBIN="/Users/riandyrn/go/bin"
GOCACHE="/Users/riandyrn/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/riandyrn/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.4/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
GOROOT/bin/go version: go version go1.12.4 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.12.4
uname -v: Darwin Kernel Version 16.5.0: Fri Mar  3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.12.4
BuildVersion:	16E195
lldb --version: lldb-370.0.42
  Swift-3.1
@andybons andybons changed the title [Server Not Drop Client Connection After Write Timeout] question: net/http: why does a server not drop client connection after write timeout? May 14, 2019
@julieqiu
Copy link
Member

For asking questions about learning the language, see one of our forums: https://golang.org/wiki/Questions We only use this issue tracker for tracking bugs. People in the forums can explain what is happening here.

@golang golang locked and limited conversation to collaborators May 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants