Description
- What version of Go are you using (
go version
)?
go1.7rc2
go1.6.3
go1.6 if you use http2 (custom Transport without ExpectContinueTimeout) - What operating system and processor architecture are you using (
go env
)?
linux_amd64 - What did you do?
https://play.golang.org/p/7nC5EIVRCq (change my_cert
, my_key
and my_host
)
Set a ReadTimeout
on http.Server
. Make several requests to the server using the same client (so that the TCP conn is re-used). With http2 program exits with 'unexpected EOF' after ReadTimeout
.
- What did you expect to see? 5. What did you see instead?
Program should run forever.
This works:
GODEBUG=http2client=0 go run the_file.go
This fails:
go run the_file.go
Program exits after ReadTimeout
because the TCP connection hits it's deadline, is closed. This means that in http2 ReadTimeout
applies not to a single request but to the keep-alive connection.
The deadline is set here during TLS handshake: https://github.com/golang/go/blob/master/src/net/http/server.go#L1501-L1503
In http1 case the deadline is reset every request: https://github.com/golang/go/blob/master/src/net/http/server.go#L743-L751
In http2 it is never reset. I suspect the solution is to reset the deadline here: https://github.com/golang/net/blob/master/http2/server.go#L579-L602
There is a similar problem with WriteTimeout
. The example program will hang after WriteTimeout
.
This was fixed for http1 in #4676.
Activity
[-]http.Server.ReadTimeout never reset in http2[/-][+]net/http2: http.Server.ReadTimeout never reset in http2[/+][-]net/http2: http.Server.ReadTimeout never reset in http2[/-][+]net/http: http.Server.ReadTimeout never reset in http2[/+]bradfitz commentedon Jul 21, 2016
I haven't had time to investigate this yet, but if this isn't a regression from Go 1.6, it's hard to justify fixing it this late in the Go 1.7 cycle.
bradfitz commentedon Jul 21, 2016
(I do admit that it's a regression from Go 1.5, but I'm surprised nobody has mentioned it in the last year)
grahamking commentedon Jul 21, 2016
I agree it's strange that no-one else has mentioned it, and I did do a fair amount of searching. If you reproduce it, maybe 1.7 could add a documentation note that those timeouts are not supported on http/2 connections?
http2: in Server, disarm connection's ReadTimeout after first request
bradfitz commentedon Sep 30, 2016
Bug is fixed in x/net/http2 now, but keeping this open until we figure out #14204 (Server.IdleTimeout) and add tests.
gopherbot commentedon Oct 25, 2016
CL https://golang.org/cl/32024 mentions this issue.
10 remaining items