Set_time_limit () timeout

I have a download form that uploads mp3 to my website. I have some intermittent issues with some users that I suspect are slow send connections ...

But in any case, the first line of code is set_time_limit(0); , which fixed it for users who had connections that occasionally downloaded, but some of them still lose time, and I have no idea why.

It says that the script has exceeded the limit of 60 seconds. The script has no loops, so it doesn’t like some kind of infinite loop.

It is strange that no matter what line of code is in the first line, it will always say "error on the first, second, etc.", even if it is set_time_limit(0); . I tried to erase it, and the very first line of code always seems to be a mistake, it does not even give me a hint why it cannot execute a php page.

This is a problem that few users experience, and no one else seems to be affected. Can anyone think about why this might happen?

+4
source share
3 answers

set_time_limt () will only affect the actual execution of the PHP code on the page. You want to set the PHP max_input_time directive, which determines how long the script will take input (e.g. files) for. The trick is that you need to set this in php.ini, as if max_input_time is exceeded, it will never reach the script that tries to change it with ini_set ().

+6
source

Of course, a few things noted in the PHP Manual.

Make sure PHP is not running in safe mode. set_time_limit does not affect when PHP is running in safe_mode.

Secondly, and this is where I assume that your problem lies ..... Note. The set_time_limit () function and the max_execution_time configuration directive only affect the execution time of the script itself. Any time spent on activity that occurs outside the execution of the script, such as system calls using system (), thread operations, database queries, etc., is not taken into account when determining the maximum time during which the script is executed. This does not apply to Windows, where the measured time is real.

So your flow may be the culprit.

Can you post a little of your download script, you call a separate file to handle the download using headers?

+1
source

Try ini_set('max_execution_time', 0); .

0
source

Source: https://habr.com/ru/post/1300362/


All Articles