When the onLoad function is called this code runs. The timeout is set to 2 minutes but the server always returns an error after 10 seconds despite the timeout field. How can I set the timeout to be longer?

sforce.connection.sessionId = "{!$Api.Session_ID}";
    url : '{!endpointUrl}',
    requestHeaders: {
    requestData: xmlBody ,
    method: "POST",
    onSuccess : function(response) {
        var parser = new DOMParser();
        var xmlDoc = parser.parseFromString(response,"text/xml");
        var pdf = xmlDoc.getElementsByTagName("Contents")[0].childNodes[0].nodeValue;
        document.getElementById("PdfObject").src = "data:application/pdf;base64," + pdf;
    onFailure : function(response) {
        alert("There was a problem. Please try refreshing the page or try again at another time. " + response);

See Execution Governors and Limits (emphasis mine):

Per-Transaction Apex Limits

Maximum CPU time on the Salesforce servers5
Synchronous Limit: 10,000 milliseconds
Asynchronous Limit: 60,000 milliseconds

5 CPU time is calculated for all executions on the Salesforce application servers occurring in one Apex transaction. CPU time is calculated for the executing Apex code, and for any processes that are called from this code, such as package code and workflows. CPU time is private for a transaction and is isolated from other transactions. Operations that don’t consume application server CPU time aren’t counted toward CPU time. For example, the portion of execution time spent in the database for DML, SOQL, and SOSL isn’t counted, nor is waiting time for Apex callouts.

All @RemoteAction calls are synchronous, so you cannot raise it above 10 seconds. Even if you could make the call asynchronously, you would only get 60 seconds, not 120.

In order to use asynchronous functionality, your best bet may be to use a @future method (which must be void, mind) and then just do all post-processing in that Apex method.

  • Thanks @adrian. I can't seem to find any instructions on how to make it asynchronous. (I thought I had done it by setting async to true) – Carson Aug 10 '16 at 20:55
  • If you want to parse the results of your method call, you cannot use async. You can use @future, Queueable, or Batchable depending on what you are trying to accomplish. – Adrian Larson Aug 10 '16 at 20:56
  • Can any of that be done in javascript or only in the controller? Thanks again. – Carson Aug 10 '16 at 20:58
  • You can make http callouts via Javascript, but that is a topic more suitable to Stack Overflow as it is completely independent of Salesforce. – Adrian Larson Aug 10 '16 at 21:00
  • @Carson You can also use a continuation method, which lets you have the full time, if you want to callout from Apex Code. – sfdcfox Aug 10 '16 at 23:12

This help topic explains what's going on:

AJAX API remoteFunction timeout parameter respected?

Knowledge Article Number: 000176812

Description: There is a method named remoteFunction in connection.js file which is used for AJAX calls.

Details could be found at: http://www.salesforce.com/us/developer/docs/ajax/index_Left.htm#StartTopic=Content/sforce_api_ajax_queryresultiterator.htm#ajax_proxy

What ever value is passed for the timeout parameter, the function has no effect.

Is the timeout parameter in remoteFunction configurable?

Resolution: No, the remoteFunction's timeout parameter is not configurable.

When the conenction.js file is studied, we can see that the file does not have any handler for timeout argument.

The remoteFunction can be called as (bold text represent the parameters):

               url : "http://www.myExternalServer.com",
               onSuccess : function(response) {
                      alert("result" + response);

remoteFunction descritpion can be checked at:


As per instance:




The remoteFunction do not have any parameter handler for timeout argument.

You can, however, use a @RemoteAction and configure its timeout, use a Continuation method, or use the AJAX proxy.

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