Skip to content

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

Closed
@glasser

Description

@glasser

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions