Visualizzazione dei risultati da 1 a 7 su 7

Discussione: Timeout del browser

  1. #1

    Timeout del browser

    Ciao a tutti, ho bisogno di eseguire uno script PHP, la cui esecuzione richiede circa 10 ore
    Ho settato nel PHP.INI il tempo di esecuzione massimo a 600000 secondi, fin qui OK...
    Però il problema si presenta nel browser, che mi va in timeout a circa 4 ore di esecuzione...
    Esiste un browser che ha il timeout personalizzabile oppure molto lungo?
    Da precisare che il mio script comunque ogni 10 secondi manda un output a schermo, con lo stato dell'ultima azione eseguita (riuscita oppure no)...

    Ho trovato una pagina web:

    If your acceptance tests run long enough, you risk a browser time out. The browser gets tired of waiting for the web server to respond, gives up, and claims that the page or site are unavailable. Fortunately, there are workarounds.

    Here are two approaches that framework developers can take to prevent browser timeout:

    Polling

    In this scheme, the initial invocation of the run script (e.g., "run.cgi") starts up the unit tests in the background, either by using a traditional fork/detach/exec method, or by passing along the request to run the tests, along with the desired output filename, to some compute server process. The run script then returns a page that contains an embeded "refresh" directive. This directive invokes a script that tests to see if the output file is available. If the file is available, it is returned to the browser. Otherwise, another refresh page is returned.

    In effect, the browser is polling the server until the server has completed running the acceptance tests.

    The end user sees a set of one or more "Running..." pages, and then they see the results.

    The benefit of this scheme is that the user gets periodic feedback.

    Heartbeats

    In this scheme, the server arranges to send the browser a sequence of "hearbeat" messages (in the form of HTML comments) followed, eventually, by the output file. As long as the browser gets heartbeats, it won't time out.

    To work this scheme, the run script forks, running the acceptance test in the child process. Meanwhile, the parent process enters a poll/sleep/keepalive loop, periodically emitting "". When the parent detects that the child process has completed, the parent sends the output file to the browser. The leading HTML comments emitted as heartbeats don't affect page display.

    The benefit of this scheme is relative simplicity. The downside is that users get no feedback while the tests run.
    Il metodo del commento "" lo devo provare, ma non penso funzioni, mentre il primo metodo in pratica è quello di caricare sempre una pagina che dà lo stato della successiva, fino a quando la successiva non è pronta, e questo è interessante... Ma come lo faccio?

    Il mio script fa questo, è possibile fare una pagina interna del server che controlli continuamente (tipo ogni 10 secondi) se ha eseguito tutte le richieste, in modo da evitare di mandare in timeout il browser? Oppure è possibile caricare la pagina senza browser? Cioè far fare delle operazioni interne al server ?

    Codice PHP:
    <?
    $totale 
    $_POST['totale'];
    $numeri 0;

    while ( 
    $numeri $totale ) { 

    $numeri $numeri 1;

    $variabile $_POST["casella$numeri"];

    $variabile ereg_replace(" ","",$variabile);

    $ok fopen("http://www.*******/***/*****.php?num=$variabile&doc=$doc",'r'); //Dove ***** e' per nascondere il sito che vado a caricare 
    echo "Attendo 10 secondi...
    "
    ;
    echo
    ""//Aggiunta ora per testare dopo
    sleep(10);

    if (!
    $ok) {

    echo 
    "[B]$numeri[/b]) Richiesta [b]NON[/b] Inviata a $variabile
    "
    ;

    } else {

    echo 
    "[B]$numeri[/b]) Richiesta Inviata a [B]$variabile[/b]
    "
    ;

    }

    fclose($ok);

    }

    ?>
    Sperando in un vostro aiuto, vi auguro buona notte

  2. #2
    Dopo l'eco prova a fare un flush
    Cmq uno script che ci mette tanto andrebbe lanciato da linea di comando o da cron, che senso ha lanciarlo nel browser?

  3. #3
    Originariamente inviato da margherite
    Cmq uno script che ci mette tanto andrebbe lanciato da linea di comando o da cron, che senso ha lanciarlo nel browser?
    Concordo pienamente.

    Comunque, puoi provare anche con set_time_limit impostando seconds a zero.


    "Chi non è in grado di riconoscere la piccolezza delle grandi cose che ha in sè, tende a trascurare la grandezza delle piccole cose negli altri."

  4. #4
    Cmq uno script che ci mette tanto andrebbe lanciato da linea di comando o da cron, che senso ha lanciarlo nel browser?
    Se mi spiegate come lanciarlo (essendo in remoto) da cron (cos'è?) o da linea di comando (come si fa?) ve ne sarei grato!
    Riga di comando sarebbe SSH?

  5. #5
    Ho appena abilitato l'accesso SSH (è l'unico con riga di comando che ho sullo spazio), ora entro nel server, e posso usare i comandi del terminal di Linux... Ma come eseguo uno script PHP?

  6. #6
    Leggi qui


    "Chi non è in grado di riconoscere la piccolezza delle grandi cose che ha in sè, tende a trascurare la grandezza delle piccole cose negli altri."

  7. #7

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.