Late to the party here, but it concerns the problem that I am now facing ...
I have a web server running on a platform with limited resources (128k Flash, 48k RAM), so it can only process one connection at a time. Further connections are not processed until the current one is closed. Also, it does not force Connection: close
on certain URLs due to the low latency requirement. In general, only one thing is talking at the same time with the device.
AJAX connections comply with any rules that the browser sets for other connections. In my case, I am testing a webpage that uses AJAX to read one of the URLs supported in live mode once per second, and the browser does not close the connection until a few seconds after the window closes. As a result, other customers wait indefinitely.
So, do not assume that the XHR connections are closed upon completion. They may not be like that; Firefox 21 does not close them.
My current problem is that I want my AJAX requests to close the socket upon completion, and I use jQuery .ajaxSend()
pre-send hook to set the Connection: close
header. AJAX seems to work, but when another client tries to connect, it gets a “reset from peer connection”, so I wonder if Firefox noticed the “Connection: close” header in the XHR request and keeps its socket end open (until it expires) after about three seconds) even after the server has closed its side.
source share