I am getting Read timeout error while calling a third party REST API.

Can I catch it using try catch block? Or it is not catchable like other Limit Exceptions. Please explain.

  • did you try to catch it and couldn't?
    – Saariko
    Sep 27, 2012 at 9:28
  • I tried but this error occurs time to time and i am calling third party REST API. So i don't have much control over it.
    – doga
    Sep 27, 2012 at 9:35
  • 1
    can you paste some code?
    – Saariko
    Sep 27, 2012 at 9:52
  • 6
    Try setting the timeout to 60 secs, req.setTimeout(60000); Sep 27, 2012 at 14:00

1 Answer 1


Yes, you can catch the CalloutException; from the Apex Web Services and Callouts wiki article:

try {
    //Execute web service call here     
    HTTPResponse res = http.send(req);  

    //Helpful debug messages
} catch(System.CalloutException e) {
    //Exception handling goes here.... retry the call, whatever

As logontokartik mentions in the comment above, you can also set the timeout on the callout:

req.setTimeout(60000); // timeout in milliseconds - this is one minute

The default timeout is 10 seconds. The minimum is 1 millisecond and the maximum is 120 seconds.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .