Omitir navegación
Coding for PHP curl call timeouts and re-tries in CPM customizations
ID de respuesta 11903   |   Revisado 16/06/2021

What is the best way to manage PHP curl call timeouts and re-tries in CPM customizations?


Process Designer, Custom Processes (CPM)
All product versions


The use of an appropriate timeout is required with use of PHP curl in a CPM customization. In addition to specifying a timeout value in code, there are other considerations to make in terms of the potential to retry the call if the request times out. 

What is an appropriate timeout?

A curl call timeout of five seconds is highly recommended. This value provides enough time for most integration requests to complete, and is small enough to ensure that the asynchronous CPM queue does not fall behind, or become backlogged, in other words. A larger timeout is valid if the volume of transactions processed by the queue allows for it, for any given implementation.

When a curl call reaches a configured timeout threshold, should I ensure that the request is re-tried?

When a request is made to an integration, and the PHP curl call hits the configured timeout, the PHP process stops waiting for the response from the integration. This, however, does not mean that the request will fail or need to be re-tried. This means the requesting PHP script will not have a response to analyze, in order to determine if the request has completed successfully or not. As such, the determination as to whether or not to re-try the request depends on the individual business requirements for a specific implementation.

When a PHP curl call times out in CPM code, how do I ensure that the request is re-tried?

If it is determined that re-trying an integration call is appropriate, this can be accomplished in different ways. One way is to utilize the inherent re-try mechanism for asynchronous CPMs. This first requires that the curl call is analyzed in code, for whether or not the request timed out. If it did, then the code can throw an exception manually, to ensure the CPM is re-tried up to four additional times. 

Alternatively, the CPM code can re-try the curl call again in the same CPM run, as long as there is enough time to do so within the 157 second limit for an asynchronous CPM. Another method to re-try an integration call would be to use an API save intended to re-trigger the asynchronous CPM. For the latter to be effective there must be some change made to the object when the API save is run.

For further details see

Answer ID 8392:  CPM/Process Designer Best Practices and Guidelines

Answer ID 9640:  Connect for PHP Best Practices and Gotchas

Answer ID 6607:  Asynchronous CPM "processes" queued are removed automatically after five unsuccessful tries

Answer ID 10025:  When does a Custom Process (CPM) enter an error state?

La página se refrescará al enviar. Las entradas pendientes se perderán.