-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: check that http2 logs no more than http1 #13925
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
Comments
How are you starting your http server? Do you have explicit configuration, or the default? |
Explicit. I am setting the timeouts. func NewServer(addr string, handler http.Handler) *Server {
s := &Server{
Server: http.Server{
Addr: addr,
Handler: &serverHandler{
Handler: handler,
},
MaxHeaderBytes: 4096,
// Maximum duration before timing out read of the request
ReadTimeout: 3 * 60 * time.Second, //60e9,
// Maximum duration before timing out write of the response
WriteTimeout: 3 * 60 * time.Second, //60e9,
},
}
s.ConnState = func(conn net.Conn, state http.ConnState) {
switch state {
// StateNew represents a new connection that is expected to
// send a request immediately. Connections begin at this
// state and then transition to either StateActive or
// StateClosed
case http.StateNew:
// StateActive represents a connection that has read 1 or more
// bytes of a request. The Server.ConnState hook for
// StateActive fires before the request has entered a handler
// and doesn't fire again until the request has been
// handled. After the request is handled, the state
// transitions to StateClosed, StateHijacked, or StateIdle.
case http.StateActive:
conn.SetReadDeadline(time.Now().Add(s.ReadTimeout))
conn.SetWriteDeadline(time.Now().Add(s.WriteTimeout))
// StateIdle represents a connection that has finished
// handling a request and is in the keep-alive state, waiting
// for a new request. Connections transition from StateIdle
// to either StateActive or StateClosed.
case http.StateIdle:
// StateHijacked represents a hijacked connection.
// This is a terminal state. It does not transition to StateClosed.
//
// StateClosed represents a closed connection.
// This is a terminal state. Hijacked connections do not
// transition to StateClosed.
case http.StateHijacked, http.StateClosed:
}
}
return s
} |
I've clarified the docs for ConnState StateActive in https://go-review.googlesource.com/18575:
ConnState is mostly used for graceful shutdowns of servers. If you want to adjust read and write deadlines per-request, you'll also need to install a http.Handler wrapper which does that (cooperating with the ConnState hook to map between the net.Conn and the http.Request.RemoteAddr) |
CL https://golang.org/cl/18575 mentions this issue. |
Update #13925 Change-Id: I7cd0625fad841eb0e3f364629f9bc225aa2fdce9 Reviewed-on: https://go-review.googlesource.com/18575 Reviewed-by: Andrew Gerrand <[email protected]>
I'll audit the http2 logging paths and make sure they're not any more verbose than http1 for Go 1.6. |
CL https://golang.org/cl/18932 mentions this issue. |
Recognize connection aborted errors on Windows and don't log them by default, like the Unix case. Log frame reading errors only at verbose level, to match net/http.Server. Updates golang/go#13925 Updates golang/go#14061 Change-Id: I87998a924b11d4dad5512e010b29d2da6b4bf867 Reviewed-on: https://go-review.googlesource.com/18932 Reviewed-by: Ian Lance Taylor <[email protected]>
CL https://golang.org/cl/18934 mentions this issue. |
Why are these logged by default?
If I understand it correctly, it's not an error; it's just that the client wants to keep a connection open for a longer time than the server (the
ReadDeadline
times out).The text was updated successfully, but these errors were encountered: