SFDC Mobile SDK API Call - Request Timeout

729 Views Asked by At

Hybrid Mobile App Cordova 8.0.0 Angular 1.7.5 Salesforce MobileSDK 6.2

Method - force.apexrest Issue - Salesforce REST API Call - Request Timeout (20%).

Details - When the mobile app is hitting an SFDC custom REST API then sometimes it gets Request Timeout (incase app does not get the response from SFDC API within a time period).

Is there any configuration setting in Mobile SDK where we can set (increase) this timeout period ?

1

There are 1 best solutions below

0
Chetan Shrivastava On BEST ANSWER

The default timeout is 10 seconds.

The maximum cumulative timeout for callouts by a single Apex transaction is 120 seconds.

Setting Callout Timeouts:

The following example sets a custom timeout for Web services callouts. The example works with the sample WSDL file and the generated DocSamplePort class described in Generated WSDL2Apex Code. Set the timeout value in milliseconds by assigning a value to the special timeout_x variable on the stub.

1) docSample.DocSamplePort stub = new docSample.DocSamplePort();

stub.timeout_x = 2000; // timeout in milliseconds

The following is an example of setting a custom timeout for HTTP callouts:

1) HttpRequest req = new HttpRequest();

req.setTimeout(2000); // timeout in milliseconds

For more details please read this link: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_timeouts.htm