[SalesForce] Javascript Remoting timeout

my question may be silly, but just curious to know.

In the documentation, it is given as
Visualforce.remoting.timeout: The timeout for the request, in milliseconds. The default is 30000 (30 seconds). The maximum is 120000 (120 seconds, or 2 minutes).

Question: Let us say, my Visualforce page invokes an Apex method 2000 times (i put 'Visualforce.remoting.Manager.invokeAction' in a For loop). Is the max time for total 2000 calls or for each individual call?

Best Answer

This depends on the current state of buffering. By default, methods called close together are buffered together and sent all at once. The documentation hints that the limit may be per each buffered transaction (but it isn't clear, so I'd have to test). You can disable buffering as described in JavaScript Remoting for Apex Controllers in order to prevent buffering. This may greatly increase the time it takes for the page to load data, but will reduce errors related to maximum response sizes and timeouts. The rationale behind this answer is that the timeout is controlled on the client side, not server side, meaning that each buffered request would have a single client-side timeout aggregated together.

Related Topic