Long polling freezes browser and block other ajax request Long polling freezes browser and block other ajax request ajax ajax

Long polling freezes browser and block other ajax request


Seems like you experienced the session file lock

For PHP

Use session_write_close() when you don't need session value


It seems you have an empty while loop in your browser code.. this is a very CPU instensive way to wait for an event.

If no events happen the client will kill the request after your desired timeout of 50 seconds. But I'm not sure if the server thread is killed too, or if it "whiles" on forever (unless there is an event). The next request will start a second server thread that hangs in the while loop too then. Maybe the amount of empty while loops is an overkill for the server, so that it stops accepting any more requests. So after some requests (that each triggered an endless server thread) the client waits forever on a new request.. because it can't be handled by the server.

ps: on success you commented to wait 1 second, but set the timeout to 10000 (10 seconds)


I've met similar problem, my browser was stucked somehow with AJAX requests. Hint: instead using waitForMsg() directly, try setTimeout("waitForMsg()",10).