Issue with HTTPS client and AWS ELB

231 views
Skip to first unread message

Evan Shaw

unread,
Apr 12, 2012, 5:30:28 AM4/12/12
to golang-nuts
I've been tracking down a bug in a web API client library and I think
I've found a bug in the crypto/tls package. My symptom is that my
requests occasionally fail with io.EOF. I'll attempt to describe what
I think is the cause.

ELB is the AWS load balancer. When its load suddenly increases, it can
respond with HTTP 503 errors while it warms up. When it does this over
HTTPS, it also sends a TLS close_notify alert but does not close the
connection itself.

Go's http package receives ELB's 503 responses just fine. However, it
does not read the close_notify alert and so doesn't realize that the
TLS connection is effectively closed. It then tries to reuse the same
connection for its next request. The writes all succeed, but ELB is
completely ignoring everything. Then http attempts to read the
response, the tls.Conn sees the close_notify alert from the previous
response, and the read returns io.EOF.

I think something needs to change in crypto/tls, but I'm not sure of
the best approach. It seems like the writes in the last request should
fail and http should figure out it needs a new connection.

- Evan

André Moraes

unread,
Apr 12, 2012, 8:09:52 AM4/12/12
to Evan Shaw, golang-nuts
>
> I think something needs to change in crypto/tls, but I'm not sure of
> the best approach. It seems like the writes in the last request should
> fail and http should figure out it needs a new connection.
>
> - Evan

As a temporary solution you could try closing the connections after
the 503 response.

http://golang.org/pkg/net/http/#RoundTripper

http://golang.org/pkg/net/http/#Transport

--
André Moraes
http://andredevchannel.blogspot.com/

Brad Fitzpatrick

unread,
Apr 12, 2012, 11:03:53 AM4/12/12
to Evan Shaw, golang-nuts
Let's move this into a bug and discuss there.

Once you file it, reply to this thread with the bug URL.  Copy me and a...@golang.org on it.

Thanks!

Evan Shaw

unread,
Apr 12, 2012, 4:03:52 PM4/12/12
to Brad Fitzpatrick, golang-nuts
On Fri, Apr 13, 2012 at 3:03 AM, Brad Fitzpatrick <brad...@golang.org> wrote:
> Let's move this into a bug and discuss there.
>
> Once you file it, reply to this thread with the bug URL.  Copy me and
> a...@golang.org on it.

Done: http://code.google.com/p/go/issues/detail?id=3514

I'm not able to add CCs to issues. Could please do it?

- Evan

Brad Fitzpatrick

unread,
Apr 12, 2012, 4:40:21 PM4/12/12
to Evan Shaw, golang-nuts
Done.
Reply all
Reply to author
Forward
0 new messages