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/httputil: timeout on ReverseProxy that bridges long-poll conversations #9641

Closed
proteneer opened this issue Jan 20, 2015 · 2 comments

Comments

@proteneer
Copy link

What version of Go are you using (go version)?

go version go1.3.3 darwin/amd64

What operating system and processor architecture are you using?

OS X Yosemite

What did you do?

I'm proxying a long-polling request using:

    remote, err := url.Parse("http://localhost:7500")
    if err != nil {
        panic(err)
    }
    proxy := httputil.NewSingleHostReverseProxy(remote)
    router.Handle("/endpoint", proxy)

Note that /endpoint is a local address that takes 300 seconds to finish. I mocked this.

What did you expect to see?

A proxied response.

What did you see instead?

Times out if /endpoint takes too long to reply (eg. due to long-polling). The proxy seems to completely drop the response (but oddly enough, only after 300 seconds). Curl'ing the /endpoint on the Go server results in a "curl: (52) Empty reply from server", even though data should be written out.

@mikioh mikioh changed the title ReverseProxy timeout net/http/httputil: ReverseProxy timeout Jan 20, 2015
@mikioh
Copy link
Contributor

mikioh commented Jan 20, 2015

It seems like your issue depends on your proxy and long-polling HTTP server stuff. Can you provide a simple, minimum reproducible example code for both entities?

FWIW, the value 300 seconds is probably because;

var DefaultTransport RoundTripper = &Transport{
    Proxy: ProxyFromEnvironment,
    Dial: (&net.Dialer{
        Timeout:   30 * time.Second,
        KeepAlive: 30 * time.Second,
    }).Dial,
    TLSHandshakeTimeout: 10 * time.Second,
}

and

# sysctl -a | grep tcp.keepcnt
net.inet.tcp.keepcnt: 8

On darwin that means that; tcp.keepidle=30s + (8 x tcp.keepintvl=30s) + extra/roundup value eq 300 seconds

@mikioh
Copy link
Contributor

mikioh commented Jan 20, 2015

I just tried http://play.golang.org/p/e7gt8KgqnX and http://play.golang.org/p/95zkaySHHs, and got no failure. Looks httputil.ReverseProxy is working as intended.

client any/tcp --> 8080/tcp proxy any/tcp --> 9999/tcp godoc 

Please consult https://groups.google.com/forum/#!forum/golang-nuts if you have any questions on the net/http, net/http/httputil packages. A lot of experienced gophers are out there.

@mikioh mikioh closed this as completed Jan 20, 2015
@mikioh mikioh changed the title net/http/httputil: ReverseProxy timeout net/http/httputil: timeout on ReverseProxy that bridges long-poll conversations Jan 20, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

3 participants