I have an interactive web page that upon user interaction makes asyncronous requests to the server (loading images, data, etc.).
As a final stage I'm implementing the JavaScript code in order to handle properly situations where the server is too busy or a network congestion occurs and a request is not satisfied.
During development both server and client (browser) run on the development machine (localhost).
To test the code I have to simulate on my local development machine those situations.
I can easily simulate a "Service Unavailable" response.
But how can I simulate a "no response at all" ?
Is placing
sleep(3600);
at the beginning of the php
that get executed when the request is made enought to achieve what I need to simulate?
Or does something still goes back to the browser?
Is there a better way to test browser-side code in poor-server-availability situations?
Edit
One option is to just shut down the server running on localhost as suggested by Dave in his answer.
I'd prefer -if possible- to avoid that.
I'd like to be able to miss some requests and satisfy some others.
The idea behind that is that the client side JavaScript code running on the browser will retry failed requests.
The server simulates unavailability for one request, the client retries, the server give the response...