-2

I do some API request use php(cURL), but I have problem in cURL_exec(), for some case it always Fatal error max. execution. How to fix it? really need help

O. Jones
  • 103,626
  • 17
  • 118
  • 172

2 Answers2

0
ini_set('max_execution_time', 500); //500 seconds
Mohcin Bounouara
  • 593
  • 4
  • 18
  • 2
    Please add some information on why this could fix the OPs problem – Kasia Gogolek May 02 '18 at 11:09
  • WordPress last version By default limits maximum execution time is 30 seconds.. that why gives you a problem.. Add the following code to .htaccess if you dont wanna work with PHP script: php_value max_execution_time 5000000 will work.. hope :) – Mohcin Bounouara May 02 '18 at 11:22
  • 2
    Dont add information as comment. Edit your answer instead! – GhostCat May 02 '18 at 12:50
  • If you edit your answer to include the information from your comment, it would actually be a decent answer. – Sean the Bean May 02 '18 at 15:22
0

there may be several different time limits at play here, first, when running php outside of cli mode, there's usually a php max execution time limit, which you can change with the set_time_limit() function, if you're running php behind fpm, there's usually fpm read timeout with whatever fpm client you're using (eg, for nginx+php-fpm, you'd need to change nginx's fastcgi_read_timeout variable), and the curl api itself has timeouts on how long curl_exec is allowed to run, called CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT, which you can edit with the curl_setopt() function.

hanshenrik
  • 19,904
  • 4
  • 43
  • 89