-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
x/net/http2: Incompatibility between library and built-in net/http transport ("bogus greeting") #22481
Comments
Can you post a complete repro with code? It's possible that you're not using TLS. Currently, net/http's H2 support requires TLS. |
I don't have a minimal repro yet but can try to work one up (if you're willing to source from some external packages I can make one pretty trivially). However, TLS is always used. |
This works just fine for me using a self-signed cert: package main
import (
"crypto/tls"
"fmt"
"net/http"
"golang.org/x/net/http2"
)
func main() {
http.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
fmt.Printf("Got request %v\n", req.URL)
rw.WriteHeader(204)
})
go func() {
var srv http.Server
srv.Addr = "localhost:8999"
http2.ConfigureServer(&srv, nil)
srv.ListenAndServeTLS(cert, key)
}()
t := http.DefaultTransport
t.(*http.Transport).TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
}
req, err := http.NewRequest("GET", "https://localhost:8999/foo", nil)
if err != nil {
fmt.Printf("NewRequest: %v\n", err)
return
}
resp, err := t.RoundTrip(req)
if err != nil {
fmt.Printf("RoundTrip: %v\n", err)
return
}
fmt.Printf("Got response %v\n", resp.StatusCode)
} Tested with go 1.9.1 and HEAD. I haven't tried go 1.9.2, but I'm not aware of any HTTP changes in 1.9.2. Does the above program work for you? |
After a bunch more testing and digging in, I think what has happened here is that due to some unrelated changes we ended up in a state where http2.ConfigureTransport was no longer being called but the TLS config for the connection was specifying a NextProtos of Sorry for the noise and thanks for helping! |
What version of Go are you using (
go version
)?1.9.2
Does this issue reproduce with the latest release?
Yes (1.9.2 is currently the latest.)
What operating system and processor architecture are you using (
go env
)?What did you do?
Created an
http.Server
and calledhttp2.ConfigureServer
on it withnil
configuration.What did you expect to see?
Working behavior regardless of whether an
http.Transport
is using the Gonet/http
package's built-in H2 support or thehttp2
package's support.What did you see instead?
When an
http.Client
is used with anhttp.Transport
using the built-innet/http
H2 support, abogus greeting
message:If the
http.Transport
hashttp2.ConfigureTransport
called on it, everything works normally.This appears to have started happening somewhere between September 5th and October 27th, since I first started seeing this behavior after a vendored dependency update. Before then, the transport worked fine regardless of whether it was using
http2.ConfigureTransport
or not.The text was updated successfully, but these errors were encountered: