Re: Simultaneous calling two PHP scripts



Bart Friederichs wrote:
Hi,

I am working on a push-technology system that uses long-polling to fetch
information from the server. To do so, I created a JavaScript that runs
a XMLHttpRequest, connecting to a PHP script. The script only returns
when data is available and sleeps when no data is there. After 1 minute,
it returns with empty data. After data received, the JavaScript
immediately runs the same XHR.

The problem that I encountered now, is that I cannot run two of these
calls simultaneously. If I have one XHR in 'wait' state (so the PHP
script is sleeping), no other XHR call completes until the first one
finished. It seems like the sleeping PHP thread is blocking any
subsequent communication with the server.

Is there a way to work around this or fix it?

Regards,
Bart

PS
Using PHP 5.2.6-2ubuntu4.1 on apache 2.2.9 (Ubuntu)

Are you using sessions in your PHP page? A session is single threaded on the server.

If so, you should call session_write_close() before waiting to free up the session for another request. Bear in mind, however, you will no longer be able to update the session.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages