Retry the HTTP roundtrip a few times if it fails the first time.
Retry the HTTP roundtrip a few times if it fails the first time.

Try sending a request up to 10 times, with 30 seconds in between each
try.

App Engine seems to return a run of 500 errors a few times a day, for
reasons that are not obvious. It appears that most of the time, just
trying a request again after a few seconds makes it start working again.
Previously, we were giving up on a circuit the first time a request
failed.

Retrying a request doesn't make conceptual sense, because we don't know
if the remote server received the bytes we sent already. (We don't know
whether the error happened on the way out or on the way back.) But it
seems that in practice the error usually happens on the way out.
Retrying a few times is working better for me for long-lived
connections. My system tor is getting disconnected from IRC only about
zero or one time a day, rather than the five or six times it was getting
without retries.

A retry looks like this:

2014/05/27 08:58:07 status code was 500, not 200; trying again after 30 seconds (9)

Occasionally all the retries will still fail. It looks like:

2014/05/28 00:02:21 status code was 500, not 200; trying again after 30 seconds (9)
2014/05/28 00:02:51 status code was 500, not 200; trying again after 30 seconds (8)
2014/05/28 00:03:22 status code was 500, not 200; trying again after 30 seconds (7)
2014/05/28 00:03:54 status code was 500, not 200; trying again after 30 seconds (6)
2014/05/28 00:04:24 status code was 500, not 200; trying again after 30 seconds (5)
2014/05/28 00:04:54 status code was 500, not 200; trying again after 30 seconds (4)
2014/05/28 00:05:25 status code was 500, not 200; trying again after 30 seconds (3)
2014/05/28 00:05:55 status code was 500, not 200; trying again after 30 seconds (2)
2014/05/28 00:06:25 status code was 500, not 200; trying again after 30 seconds (1)
2014/05/28 00:06:55 error in handling request: status code was 500, not 200

arlolra/meek,gorshell/forkmeek,wyuelin/mymeek,scucoco/meek,Yawning/meek,gorshell/forkmeek,infinity0/meek,wyuelin/mymeek,arlolra/meek,arlolra/meek,scucoco/meek,infinity0/meek,infinity0/meek,Yawning/meek,projectarkc/meek,Yawning/meek,projectarkc/meek,Yawning/meek,wyuelin/mymeek,projectarkc/meek,scucoco/meek,gorshell/forkmeek,projectarkc/meek,projectarkc/meek,gorshell/forkmeek,infinity0/meek,infinity0/meek,wyuelin/mymeek