Skip to content

net/http: http.Server.ReadTimeout never reset in http2 #16450

Closed
@grahamking

Description

@grahamking
  1. What version of Go are you using (go version)?
    go1.7rc2
    go1.6.3
    go1.6 if you use http2 (custom Transport without ExpectContinueTimeout)
  2. What operating system and processor architecture are you using (go env)?
    linux_amd64
  3. 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.

  1. 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

self-assigned this
on Jul 20, 2016
changed the title [-]http.Server.ReadTimeout never reset in http2[/-] [+]net/http2: http.Server.ReadTimeout never reset in http2[/+] on Jul 20, 2016
added this to the Go1.8 milestone on Jul 20, 2016
changed the title [-]net/http2: http.Server.ReadTimeout never reset in http2[/-] [+]net/http: http.Server.ReadTimeout never reset in http2[/+] on Jul 21, 2016
bradfitz

bradfitz commented on Jul 21, 2016

@bradfitz
Contributor

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

bradfitz commented on Jul 21, 2016

@bradfitz
Contributor

(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

grahamking commented on Jul 21, 2016

@grahamking
Author

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?

added
TestingAn issue that has been verified to require only test changes, not just a test failure.
on Sep 30, 2016
bradfitz

bradfitz commented on Sep 30, 2016

@bradfitz
Contributor

Bug is fixed in x/net/http2 now, but keeping this open until we figure out #14204 (Server.IdleTimeout) and add tests.

added
NeedsFixThe path to resolution is known, but the work has not been done.
on Oct 7, 2016
gopherbot

gopherbot commented on Oct 25, 2016

@gopherbot
Contributor

CL https://golang.org/cl/32024 mentions this issue.

10 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.TestingAn issue that has been verified to require only test changes, not just a test failure.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bradfitz@quentinmit@grahamking@gopherbot

        Issue actions

          net/http: http.Server.ReadTimeout never reset in http2 · Issue #16450 · golang/go