Frequently Asked Questions
If you set a timeout on an operation invocation, such as by explicitly setting a timeout with ice_timeout, or by setting the Ice.Override.Timeout property, you may find that the operation times out later than expected. For example, the client may set a timeout of 5 seconds but receive a TimeoutException only after 10 seconds.
The most common cause for seeing timeouts that are "too long" is a retry. By default, the Ice run time will transparently retry a failed invocation behind the scenes if there is a chance that a second attempt might succeed, provided the run time can guarantee that doing so will not violate at-most-once semantics. In addition, if an operation is marked as idempotent, a retry will occur even there is a chance that the operation might be invoked a second time. Connection establishment and invocation timeouts are the errors that cause a retry.
As an example, if you have an idempotent operation that takes a long time (say, a minute) to complete, and you set a timeout of 5 seconds in the client, the client will receive a TimeoutException after 10 seconds. The reason is that the Ice run time sends a request for the invocation, then receives a timeout after 5 seconds and then, because the operation is idempotent, re-sends the request and waits another 5 seconds. Ice throws a TimeoutException to the application only after the second attempt times out as well.
By default, the Ice run time retries failed operation invocations once. You can change this by setting the property Ice.RetryIntervals. For example, if you set
Ice.RetryIntervals=0 1000 5000
the Ice run time will retry an invocation three times: immediately after the first failure, a second time after waiting 1 second, and a third time after 5 waiting seconds. For this example, if you set a timeout of 500ms for an invocation, a TimeoutException is raised after 8 seconds:
- The first attempt fails after 500ms.
- The run time makes a second attempt which also fails after 500ms.
- The run time waits for 1 second before making a third attempt that fails after 500ms.
- The run time waits for 5 seconds before making a fourth attempt that fails after 500ms.
You can disable retries completely by setting Ice.RetryIntervals to -1.
You can trace retry activity by setting Ice.Trace.Retry to 1 for the client. This traces the retries that are made by the Ice run time and allows to check your timeout settings.