1

I have this code

$url="site.com";//~
$opts=array(
    'http'=>array(
        'method'=>"GET",
        'header'=>"Accept: */*i\r\n".
              "User-Agent: Your application name\r\n",
        "ignore_errors" => true,
        "timeout" => 1800
    ),
    "ssl"=>array(
        "allow_self_signed"=>true,
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    )
);
$page = file_get_contents($url, false, stream_context_create($opts));
...
...

If $url (web page) is small size - script works well.

But when the size is large, and the running time begins to exceed 120 seconds -

process is going to abort and displayed 504 ERROR.

--

At the beginning of the script I add:

ini_set('max_execution_time',18000);
ini_set('default_socket_timeout',18000);
ignore_user_abort(true);
ini_set('memory_limit','512M');

In ini.php i add following:

max_execution_time = 18000;
max_input_time = 18000;

But nothing helps.

Question: How can i extend script execution time - more than 120 seconds ?

PS: All of the above (max_execution_time, ...) changed according to the specified intagers (as seen by phpinfo()). But parameters realpath_cache_size and realpath_cache_ttl (in phpinfo() written that equals 120) doesn't change. Maybe a problem on this ?

1 Answers1

0

Your code is running for as long as you set it , Infact if you simply add to the top of your code

       set_time_limit(0);

It's won't stop till it's end, However if you want to keep waiting for the output then you need to set the Apache2 timeout limit, and also your browser timeout limit.

Zack Heisenberg
  • 499
  • 6
  • 12
  • I forgot to write about set_time_limit (0), I tried it too. – Vigen Cholakyans Oct 06 '18 at 13:45
  • Apache default timeout limit is 300 sec.http://httpd.apache.org/docs/2.0/mod/core.html#timeout , and my browser timeout limit also equal 300 https://cs.chromium.org/chromium/src/net/socket/client_socket_pool.cc?sq=package:chromium&l=25 – Vigen Cholakyans Oct 06 '18 at 13:52