php - CURL request incomplete, suspect timeout but not sure -


I presentprint = "text">

I am currently running a daily cron to export product data in CSV format from the admin area of ​​a site I am using curls through php scripts.

The usual way to export the data is to go to the export page in the browser, and set up the configuration, then click the "Export Data" button. But as I am exporting is such a big product, and exporting data takes more than 5-10 minutes, I decided to use php curl function to copy it on a daily basis via cron is.

First, it is working fine, but recently when I increase the number of products in the store by 500+, the script fails to return the export data. Manually test by clicking on the "Export" button in the browser, returns the data properly, thus there is no "timeout" issue with manually running the export in a browser.

I have tested and reducing / decreasing the number of products (thus required time), php-curl script works fine when run from the cron.

So I suspect that it has something to do with the timeout problem, especially with the curl function in php.

I have set both CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT to try, in the '0' PHP-curl script, I have also set "set_time_limit (3000)" but still it does not work, and The request timed out, in which the CSV fails in the script with a complete set of data.

Any of my help in solving / understanding this issue would be greatly appreciated!

Edited: A part of the code where curl script is calling the export job.

  $ interface = new StoreInterface (); Echo "Start Export" Date ('LJS' FYH: IES A '). "\ N"; Set_time_limit (3000); $ Result_html = $ interface- & gt; Export Products (); // parse $ result_html to retain CSV format preg_match ('/ & lt; prefix (. *) & Lt; \ / pre & gt; / s', $ result_html [0], $ output) ; If (strollen ($ output [1]) <10) {// now buzz for debugging "Export was not done correctly. \ N"; Die ('unsuccessful export'); } File_put_contents ($ output_path, $ output [1]); Echo "The script completed, thank you! \ N";  

You can log in to all the curl transfer details by using the following curl options Please file and check any issues.

  $ fp = fopen ('./debag / transfer.log'); Curl_setopt ($ curl, CURLOPT_VERBOSE, TRUE); Curl_setopt ($ curl, CURLOPT_STDERR, $ fp);  

In addition, I believe the CURLOPT_TIMEOUT option does not support specifying a "0" value indefinitely. You need to specify the maximum timeout value.


Comments