When consuming any external service, don't expect the external service developer is as much smart as you are. Recently I have faced an issue when integrating with Amazon S3 that they failed to serve the data on first request, but on the consequent request they are able to return the data. So I did a little tweak in my code, instead of calling the service once, I am retrying up to 3 times. If the retry also fails the regular code block executes:
const int MAX_TRY = 3;
int tryCount = 1;
byte[] result = null;
using(AmazonS3 proxy = CreateServiceProxy())
{
while(((result == null) || (result.Length == 0)) && (tryCount < MAX_TRY))
{
try
{
result = proxy.GetObject(_bucketName, key, false, true, true, _accessKeyID, timestamp, true, signature, null).Data;
}
catch
{
tryCount += 1;
if (tryCount == MAX_TRY)
{
throw;
}
}
}
}
return result;