-
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
net/http: Request to certain server hangs, works fine with curl #21301
Comments
Apologies for the duplicate and thanks for the quick response 😄 |
Oops, nvm @bradfitz beat me to it. @wjdp if you want to use http1, please use package main
import (
"crypto/tls"
"flag"
"fmt"
"net/http"
"time"
)
func main() {
var http1 bool
flag.BoolVar(&http1, "http1", false, "use http1 to invoke the server")
flag.Parse()
tr := &http.Transport{}
if http1 {
tr.TLSClientConfig = &tls.Config{
NextProtos: []string{"h1"},
}
}
client := &http.Client{
Timeout: 30 * time.Second,
Transport: tr,
}
resp, err := client.Get("https://www.southampton.ac.uk/")
if err != nil {
panic(err)
}
fmt.Println(resp)
} and invoke it with flag http1 ie |
Thanks @odeke-em, provided snippet does the trick! |
I had a problem with a hanging host as well. On the surface very similar to this case although setting the protocol version did not work. For me it was necessary in the TLS config to use DynamicRecordSizingDisabled: true I posted a more fleshed out comment about it in: #20979 (comment) for debugging similar issues. |
@HaraldNordgren, please file a separate crypto/tls bug for your case. It sounds like a crypto/tls issue instead of a net/http issue. |
…imeout. 1. Adcording to golang/go#21301, we use http1 in transport layer to prevent timeout. 2. Set meta parser timeout to 5 second, this prevent API blocking.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8.3 linux/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
A response within a second or two
What did you see instead?
Timeout after 30 seconds, will happily hang for longer if timeout extended.
The following is the output of curl on the same machine / network. This timeout issue with this server has also been observed on a Travis test runner.
The text was updated successfully, but these errors were encountered: