TimeoutException(s), timeout related ArgumentOutOfRangeException(s) thrown from the SAP Adapter

You must have read in the documentation that the SAP adapter does not support/honour the timeout values specified on the binding (sendTimeout, openTimeout, etc). However, at times you might yet receive timeout related exceptions from the adapter. Why?

The SAP Adapter uses the SAP RFC SDK Library to communicate with SAP. The API calls in this SDK don't support timeouts, and hence, when making a call using this API, the adapter is helpless if an API invocation ends up taking a really long time. However, in most of the code paths within the adapter, the adapter performs a bunch of steps - some of them within the adapter, while the rest involving API invocations in the RFC SDK.

Now, as mentioned above, the timeout is not honored during a single API invocation. However, in between API calls, if the adapter determines that a timeout has occurred, then it does throw a TimeoutException.

But why does it throw an ArgumentOutOfRangeException at times? That is a side effect of the internal implementation; however, the error message might be something to the tune of "Timeout must be greater than or equal to TimeSpan.Zero", indicating a timeout related exception.

If you find such exceptions common in your environment, you should increase the sendTimeout value on the SAPBinding (the default is 1 minute, which might be insufficient when sending IDocs or executing BAPIs with a large amount of data, for example).