AJAX script sends a request. If processing takes more than 2 minutes, an error occurs.
Help, please, what to do in this case, so that the browser waited for a response from the script for more than 2 minutes.

    2 answers 2

    The browser waits for a response indefinitely - while the tcp connection is open. I regularly go to the pages that open for 5-10-15 minutes.

    Most likely, the connection is broken on the server side by the script timeout or by intermediate proxy or reverse proxy server by the timeout of the lack of data in the connection.

    To solve the timeout with the script, you need to look at the server settings and set large values.

    To solve problems with a proxy, from time to time send to the connection or another piece of data or something left, like a couple of thousand spaces so that the connection remains active.

    • Checked time execution skrpita = 1,4339088527953 sec, command set_time_limit (2); performed. - Maxim147
    • I have a website on the hosting, apparently the problem is in the timeout with the script - Maxim147
    • I don’t quite understand why the script execution time is less than 2 seconds, and I have to wait for minutes. - Maksim147
    • those. it is not clear then which parameter can be attached to, for example, if you set the tracking function, 1 minute 50 seconds elapsed and it gives all that is ready, plus some indicator that indicates where the stop was. - Maksim147
    • Try: set_time_limit (200) + try a script like sleep (100); print 'OK' to check if the script is interrupted due to a timeout or for other reasons. If due to a timeout - consult with the hoster on what it is and whether it can be increased. If for another reason - debugging and asking. - rekby

    Look at the phpinfo() output for the max_execution_time . If it is close to 120 (seconds) - the problem is in it.

    In this case, you will be helped by increasing (or setting to 0, that is, "without restrictions") this limit with set_time_limit () .

    • Yes, that's it. But setting set_time_limit () changes nothing. Apparently it's about hosting settings. Perhaps something to do with this or work around a problem? - Maksim147
    • What does "setting set_time_limit () change nothing"? What is the max_execution_time in phpinfo() before setting the set_time_limit() hands, what is the after? - AntonioK