Browser hangs till Timeout from server after cancelling HttpRequest
I have a flex application that requires multiple and long http requests to get data from server. During runtime, a random http request simply hangs. The browser network panel shows http request pending and till exactly five minutes. During this time, any request made from the same browser session to that hostname does not load at all(pending).
I tried modifying the keep-alive request headers but the server response seem to reset to the default value which is any way just 5 seconds.
I found the value of 300s in apache conf under Timeout Directive. On changing the Timeout from 300 to 30, the browser-host hangup changed to 30 seconds. Why is the browser waiting for the Timeout message after cancelling the httpRequest even in a new tab?
I am closing the actionscript urlstream using ustream.close() . The urlstream is re-initialized with ustream = new URLStream(). On initializing without close, the previous request goes to completion causing slower loading and high bandwidth. I fear the actionscript close() is not able to give a proper closure to the http request, but it happens only some times.
The culprit was php session locks. The php files called by the server used to fetch some data from the session. PHP uses session locks to ensure consistency in session data. Hence, at a time only a single file can remain open connection to the server. When the urlstream is closed from the browser side, apache takes up the next request but waits till the previous completes or is timed out. The solution was to make sure that all sessions in php files are closed before closing the stream.
To further decrease the server overhead, I am now passing a key from GET parameter instead of maintaining sessions. session_write_close can be used to stop session from locking.
I used mod_status with ExtendedStatus On to debug the Apache process with help from this blog