I have a javascript web app set up to use long polling with a .net server, using the ajax call:
var _listenTimeout = 5 * 60 * 1000;
//...
$.ajax({
type: "GET",
url: url,
async: true,
cache: false,
dataType: "jsonp",
timeout: _listenTimeout,
success: callback
});
However, there is an issue when the page is open for a while, where requests to the server stop responding. It seems to be in a limbo state, where packets are stuck between the web browser and being sent out of the network to the server.
I've dug around, and I know a couple of things:
- The request gets sent because it shows up on the chrome web developer network tab (also chrome://net-internals) and firebug. The status of the request is always pending, and it just stalls in that state.
- The request url is correct, because sending the same url through
curl
returns an immediate response. - It hasn't left my network because there aren't any packets detected using wireshark. The server logs (and wireshark on that side) don't show anything either.
The strange thing is, sometimes it works sporadically, but with a delay of a couple of minutes ie, the browser network log detects the request gets a response (a 204 in my case), and wireshark detects the request being sent (and received on the server end). The delay is the same for both the browser and wireshark ie, the request is made, a delay occurs, then chrome detects a response and wireshare detects packets sent.
A clean refresh of the page also fixes the issue, with the same request/response occurring almost immediately (with the relevant browser network and wireshark logs).
I've tried it on Chrome 21.0.1180.89 and Firefox 14.01.
Is there some browser queue of some sort that gets clogged up in the browser with ajax requests? Or maybe too many concurrent requests? No idea right now...