Strategy to retry on HTTP failures

1,597 views
Skip to first unread message

Naitik Shah

unread,
Jun 27, 2012, 2:47:14 AM6/27/12
to golan...@googlegroups.com
I'm using a couple of libraries which wrap third party HTTP APIs (for example goamz/s3) which use the net/http package underneath. They occasionally fail with errors like "remote error: handshake failure" or "connection reset by peer" which are to be expected. But rather than failing I want to get them to retry. I was planning on patching my various call sites to deal with the retry logic at the high level API, but was wondering if anyone has advice on ways to generalize this. Most of them end up using http.DefaultClient, and I figured maybe something that automatically retries for GETs might work and get me a long way there.


--
-Naitik

Dave Cheney

unread,
Jun 27, 2012, 3:07:21 AM6/27/12
to Naitik Shah, golan...@googlegroups.com
Hello,

I'm a user of goamz and it looks like the aws service endpoint isn't
as reliable as we'd like. I think the best way to handle this would be
to raise a feature request on the goamz project. You can find it here
https://launchpad.net/goamz

As an aside, are you just trying the default region, or have you tried others ?

Cheers

Dave

Naitik Shah

unread,
Jun 27, 2012, 1:35:09 PM6/27/12
to Dave Cheney, golan...@googlegroups.com
My data is in the "US Standard" (US East?) region, but the small amount of connection failures seems reasonable imo, and I think I'm just going to handle this at each call site independently for now.


-Naitik
--
-Naitik

Kyle Lemons

unread,
Jun 27, 2012, 5:11:06 PM6/27/12
to Naitik Shah, golan...@googlegroups.com
I'm not sure about these libraries, but if they allow you to control their underlying http.Client you could put in your own custom Dial function that returns a special net.Conn with retry-on-error semantics.

Naitik Shah

unread,
Jun 27, 2012, 5:37:10 PM6/27/12
to Kyle Lemons, golan...@googlegroups.com
I'm attempting to do it at the Transport layer, though it is still pretty rough and incomplete so far: 

--
-Naitik

roger peppe

unread,
Jul 11, 2012, 6:31:18 AM7/11/12
to Naitik Shah, golan...@googlegroups.com
this is a known issue with goamz. Gustavo Niemeyer is planning
to fix it soon.

wouldn't it be nice if AWS worked more reliably?!

John Beisley

unread,
Dec 4, 2012, 2:56:44 AM12/4/12
to Naitik Shah, golang-nuts

However you do it, do include exponential backoff on retry, website admins appreciate that sort of thing!

Reply all
Reply to author
Forward
0 new messages