I have a general question about the nature of callouts and timeouts in Apex. This is probably something I should know already, but I don't.

From testing, if I set the callout timeout limit on a REST callout to 1 ms, and then run it, I get a timeout err of course, but in addition to that, the API call is not executed on the server. I assume that 1 ms is not even enough time to establish communication with the server, and it's terminated on the apex side before that can occur.

And of course, if I set it to a much longer timeout, generally the callout completes as expected. API call is executed on the server, and I get a response back.

But: is it possible to set the timeout such that the API call might execute but the timeout would be reached before I get the response back? So we'd have a successful execution but no evidence of it?

My understanding is that the answer is yes, but I want to verify.

Thanks much!


Yes and I have had this issue with servers that had a poorly performing SQL database.


  1. SF Sends the request
  2. The timeout was set to 120 sec
  3. No response was received so SF throws a Time Limit Exceeded Error

So you can catch the error and report it if needed.

Other scenarios are possible say you set the timeout for 10ms, the server is sending the response but does not do it within the 10ms, end result is the same, Time Limit Exceeded

| improve this answer | |

I did confirm that this does happen. By playing with the timeout value, and running a bunch of tests, I was able to find a value where the request was completed on the external server, but the timeout was reached before a response was received.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.