How do I use the CallRetry object in the .NET SDK?
The CallRetry object in the .NET SDK allows you to let the SDK make automatic retries on failed API calls before passing control back to your application.
You can specify the number of retries, and the types of errors and exceptions on which to make the retries, as well as any time delay in between retries.
Key properties of the CallRetry object:
DelayTime - number of milliseconds between each retry
MaximumRetries - the number of retries to make before finally giving up
TriggerErrorCodes - a StringCollection of errors codes on which to retry
TriggerExceptions - a TypeCollection of exception types on which to retry
TriggerHttpStatusCodes - an Int32Collection of HTTP error codes on which to retry
When either an API error with a code that is in the TriggerErrorCodes collection, or an exception type that is in the TriggerExceptions collection, or an HTTP error code that is in the TriggerHttpStatusCodes collection occurs, the SDK will automatically retry the call up to the number of times specified by MaximumRetries until the call returns with either a successful response or some other response that is not covered by TriggerErrorCodes, TriggerExceptions, and TriggerHttpStatusCodes.
How you use CallRetry may vary on the type of call you are making.
Here are some general guidelines on using CallRetry:
- Do not specify a large number for MaximumRetries. We recommend setting MaximumRetries to no more than 3 in all cases. This is not a hard and fast rule, but please do not have use cases where you set this to 100 for example.
- For all calls, retry on the 10007 error code.
- For all calls, retry on exceptions caused by operational issues on eBay servers. For more information on the kind of exceptions that can be caused by operational issues on eBay servers, please see this Knowledge Base entry: https://ebay.custhelp.com/cgi-bin/ebay.cfg/php/enduser/std_adp.php?p_faqid=464
- For VerifyAddItem, AddItem, ReviseItem, and RelistItem do not set error codes in TriggerErrorCodes for business logic errors which indicate things such as invalid shipping service option or invalid BuyItNowPrice. These kinds of errors must be corrected by the seller or the application before the call is tried again.
Question: Ok, all my retries have failed, now what do I do?
Answer: This depends on the actual error or exception you are getting. In general you should report 10007 errors which are persistent by filing a Support Request at http://developer.ebay.com/support/developersupport
Please provide the log entries as the details of your support request. If the issues are all in the category of eBay operational issues, please see the guidelines set forth in this Knowledge Base article: https://ebay.custhelp.com/cgi-bin/ebay.cfg/php/enduser/std_adp.php?p_faqid=464
and please do file a Support Request at
, again providing the log entries as the details of your support request.
Now for an actual code sample on using Call Retry:
CallRetry oCallRetry = new CallRetry();
// set the delay between each retry to 1 millisecond
oCallRetry.DelayTime = 1;
// set the maximum number of retries
oCallRetry.MaximumRetries = 3;
// set the API error codes on which to retry
StringCollection oErrorCodes = new StringCollection();
oErrorCodes.Add("10007"); // Internal error to the application ... general error
oErrorCodes.Add("2"); // unsupported verb error
oErrorCodes.Add("251"); // eBay Structured Exception ... general error
oCallRetry.TriggerErrorCodes = oErrorCodes;
// set the exception types on which to retry
TypeCollection oExceptions = new TypeCollection();
oCallRetry.TriggerExceptions = oExceptions;
// set the HTTP error codes on which to retry
// the "Client found response content type of 'text/plain'" problem usually happens in conjunction with an HTTP 502 error code
Int32Collection oHTTPCodes = new Int32Collection();
oCallRetry.TriggerHttpStatusCodes = oHTTPCodes;
// set CallRetry back to ApiContext
Context.CallRetry = oCallRetry;