# Retry or fallback

Source: https://developer.avalara.com/products/communications/integration-guides/communications-integration/abz0579500421784/

Guide: Communications

# Retry or fallback

Understand how to handle timeouts or errors by deciding whether to retry or wait before retrying.

After your application detects a timeout or an error, it must next make a decision whether to retry the transaction immediately or wait before retrying.

## Set a timeout value

Learn how to determine and set an appropriate timeout value for transactions.

Set your timeout setting correctly. First, run a single-line item request and note the response time. Then, add 2 to 3 seconds to this time to find the recommended client-side timeout setting. Adjust the timeout value for transactions with multiple line items.

## Retry a transaction

Learn how to retry a transaction effectively to handle timeouts and ensure successful processing.

Retry your transaction a few times if timeouts are still being returned:

1.  Retry the transaction
2.  Wait 1 second and retry the transaction
3.  Wait several seconds and retry the transaction

It’s important that you don’t retry so often that your attempts are mistaken as a denial-of-service attack. Limit your retries to 5 to 10 attempts to prevent a backlog of concurrent requests and allow the system time to recover.

Things to consider when retrying a transaction:

-   Some applications attempt to reuse HTTP connections. If you experience a connection disruption, we suggest creating a new connection for the next attempt
-   You don't know if REST v2 received your original request when you receive a timeout. REST v2 receives and processes the request successfully, but you don't receive the response. In this case, using the Commit/Uncommit functionality is helpful.

    1\. Set a unique Document Code (`doc`), such as a GUID, in your tax calculation request.

    2\. Update the Document Code (`doc`) to a new unique value if a timeout or other error is detected again.

    3\. Commit everything at once using the [Commit](https://developer.avalara.com/api-reference/communications/v2/methods/Tax%20Calculation/Commit/) endpoint once all transactions contained in your bill run are successfully processed.

## What if AFC Geo is unresponsive?

Learn what to do if AFC Geo is unresponsive during a tax calculation request.

If you’re using embedded `geolocation` (`geo` = `true` in a location object) as part of your `CalcTaxes` request and AFC Geo isn’t responding, the entire transaction fails. To resolve, turn embedded `geolocation` off (`geo` = `false`) and retry the transaction. The AFC Tax Engine determines the taxing jurisdiction based on the address information provided.

For more information, see [Geocode O](https://developer.avalara.com/communications-integration/calculate-taxes-offline/geocode-offline/)[ffline](https://developer.avalara.com/communications-integration/calculate-taxes-offline/geocode-offline).

Note

Don’t use the embedded `geolocation` functionality regularly because it impacts performance and can cause the tax calculation request to fail if AFC Geo is experiencing issues.