Skip to content
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: Timeouts are kicking in on established connections #8465

Closed
gopherbot opened this issue Aug 2, 2014 · 5 comments
Closed

net/http: Timeouts are kicking in on established connections #8465

gopherbot opened this issue Aug 2, 2014 · 5 comments

Comments

@gopherbot
Copy link

by camilo.aguilar:

I have a http client that used to work fine in Go 1.2.1 and now it does not in Go 1.3.
Basically the timeout is always kicking in the middle of a transfer. For example, when
downloading or uploading a big file. 

I also tried using the new Timeout property in http.Client instead of doing
conn.SetDeadline and I'm having the same results.

What does 'go version' print?
go version go1.3 darwin/amd64

What steps reproduce the problem?
Just use http.Client to get a big file from somewhere, the total transfer time should
take more than the time defined in Timeout.

What happened?
Timeout kicks in on an established connection

What should have happened instead?
Timeout should not kick in at all if the connection is in established state
@gopherbot
Copy link
Author

Comment 1 by camilo.aguilar:

For the record, this is the Transport I was using in Go 1.2.1
Transport: &http.Transport{
            TLSClientConfig: &tls.Config{
                InsecureSkipVerify: hc.SkipTLS,
            },
            
            
            Dial: func(network, addr string) (net.Conn, error) {
                deadline := time.Now().Add(hc.Timeout)
                c, err := net.DialTimeout(network, addr, hc.Timeout)
                if err != nil {
                    return nil, err
                }
                c.SetDeadline(deadline)
                return c, nil
            },
        },

@bradfitz
Copy link
Contributor

bradfitz commented Aug 2, 2014

Comment 2:

Please read the docs on all the various timeout knobs.  They all affect different phases
of the request.
Timeout is documented to say:
        // Timeout specifies a time limit for requests made by this
        // Client. The timeout includes connection time, any
        // redirects, and reading the response body. The timer remains
        // running after Get, Head, Post, or Do return and will
        // interrupt reading of the Response.Body.
        //
        // A Timeout of zero means no timeout.
The way you were doing it before with DialTimeout is totally different.

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Author

Comment 3 by camilo.aguilar:

Thanks for clarifying. Putting aside documentation, It is still sort of an odd and
unexpected behavior, especially in http.Client.

@gopherbot
Copy link
Author

Comment 4 by camilo.aguilar:

It would be really useful to know the exact reasoning behind that implementation because
it is out of the norm IMO.

@bradfitz
Copy link
Contributor

bradfitz commented Aug 2, 2014

Comment 5:

This isn't the place for a discussion.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants