Please answer these questions before submitting your issue. Thanks!
go version)?go 1.8
go env)?windows
Tls listener is not working as expected.
error
tls: oversized record received with length 20037
i try to read tls connection
tls: oversized record received with length 20037
This isn't enough information. Can you share a piece of code to reproduce the issue? If not, could you describe what the code was doing when this happened?
That looks a lot like trying to connect to a TLS listener with another protocol, for example plain HTTP. If that's not it, we will probably need to see the client or a pcap to debug this.
Timed out in state WaitingForInfo. Closing.
(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)
I just had a similar error... and found the following behavior weird...
Is it expected Go spitting out errors like this?
package main
import (
"fmt"
"net/http"
"net/http/httptest"
"net/url"
"os"
)
func main() {
var Mux = http.NewServeMux()
var server = httptest.NewTLSServer(Mux)
transport := &http.Transport{
Proxy: func(req *http.Request) (*url.URL, error) {
return url.Parse(server.URL)
},
}
var r, err = http.NewRequest("GET", "https://example.com/", nil)
if err != nil {
fmt.Fprintf(os.Stderr, "Unexpected error: %v\n", err)
}
_, err = (&http.Client{Transport: transport}).Do(r)
if err != nil {
fmt.Fprintf(os.Stderr, "\n\n\nUnexpected request error: %v\n", err)
}
}
When running:
$ go run foo.go
2017/05/10 10:03:18 http: TLS handshake error from 127.0.0.1:55829: tls: oversized record received with length 20037
Unexpected request error: Get https://example.com/: malformed HTTP response "\x15\x03\x01\x00\x02\x02\x16"
Notice I never printed the "TLS handshake error" error. Go just printed it to stderr. I found it really weird comparing how Go handles errors elsewhere.
Update: Actually I see it is working as intended given that http.ErrorLog is nil (https://github.com/golang/go/blob/48def43fd65388717c3edbdbbc3b3465ff9176ab/src/net/http/server.go#L2374-L2378), however the returned error value could be better, couldn't it?
Funnily enough, I hit this myself today trying to write a test.
@henvic your example is similar to what I was writing, and both are wrong:
// Proxy specifies a function to return a proxy for a given
// Request. If the function returns a non-nil error, the
// request is aborted with the provided error.
//
// The proxy type is determined by the URL scheme. "http"
// and "socks5" are supported. If the scheme is empty,
// "http" is assumed.
//
// If Proxy is nil or returns a nil *URL, no proxy is used.
Note that the "https" scheme isn't supported. I wonder if a better error should be given, as I was stuck on this for a good 20 minutes.
Sending a CL with a better error.
Change https://golang.org/cl/66010 mentions this issue: net/http: error if Transport.Proxy returns https
Most helpful comment
That looks a lot like trying to connect to a TLS listener with another protocol, for example plain HTTP. If that's not it, we will probably need to see the client or a pcap to debug this.