Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The solution could be stream_set_blocking. Use any possible blocking resource to be suspended by OS and wait for appropriate interruption. </p> <p>Client side:</p> <ol> <li>Ajax call to endpoint script (timeout for ajax e.g. 30 seconds - after 30 seconds initiate another one - after 30 seconds you will get response from server - script execution time reached)</li> <li>If you will get response during 30 seconds handle response (async) and open new connection (as in comet done - I saw it in cometD client)</li> </ol> <p>Server setup:</p> <ol> <li>Setup apache timeouts (between request and data sent to 30-31 second), this is so apache will allow you to wait so much</li> <li>set apache to allow lot of child instances (concurrent users * 1.5), but you need to be sure that you have enough memory for this amount of apache instances (+ memory used by php children)</li> </ol> <p>Script one:</p> <ol> <li>execution_time = 28</li> <li>set shutdown_function in order to send response (timeout, but formatted and understandable for ajax if You need it)</li> <li>you need to open file, empty one</li> <li>enable blocking mode using stream_set_blocking for file stream</li> <li>try read from file and you will get suspended until other process will write to file or timeout be reached.</li> <li>As soon as script gets content in file written from other process it will get back and will send response. (this will trigger another ajax call and another slept process)</li> </ol> <p>Worst thing is that you need to think how to get multiple reader scripts reading from same bus (file) without disturbing each other. Also there could be that timeout will be exactly at that time when message will be written into bus.</p> <p>(hope that this solution is not as bad as my English)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload