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: srv.Serve hangs if RemoteAddr() blocks #12943

Closed
glasser opened this issue Oct 14, 2015 · 3 comments
Closed

net/http: srv.Serve hangs if RemoteAddr() blocks #12943

glasser opened this issue Oct 14, 2015 · 3 comments

Comments

@glasser
Copy link
Contributor

glasser commented Oct 14, 2015

The PROXY protocol is supported by several proxy servers such as haproxy
and Amazon ELB. This protocol allows services running behind a proxy to
learn the remote address of the actual client connecting to the proxy,
by including a single textual line at the beginning of the TCP
connection.
http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt

There are several Go libraries for this protocol (such as
https://github.com/armon/go-proxyproto), which operate by wrapping a
net.Conn with an implementation whose RemoteAddr method reads the
protocol line before returning. This means that RemoteAddr is a blocking
call.

(Blocking inside Accept is not an option either; the point is that we want srv.Serve to call Accept on the underlying socket as soon as the previous Accept call succeeded, without any blocking operations.)

This exists in current Go master (eg, 1.5.1) on all platforms (eg, Linux).

@gopherbot
Copy link

CL https://golang.org/cl/15835 mentions this issue.

@owenthereal
Copy link

@glasser Does that mean i could use https://github.com/armon/go-proxyproto without blocking now?

@glasser
Copy link
Contributor Author

glasser commented Mar 16, 2016

@jingweno I believe so (though my project hasn't upgraded to 1.6 yet so I don't have production experience).

@golang golang locked and limited conversation to collaborators Mar 19, 2017
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