doulao2916 2018-10-06 12:17
浏览 82

120秒后504

I have this code

$url="site.com";//~
$opts=array(
    'http'=>array(
        'method'=>"GET",
        'header'=>"Accept: */*i
".
              "User-Agent: Your application name
",
        "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条回答 默认 最新

  • douqiao6015 2018-10-06 12:27
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思