views:

31

answers:

1

I've just come across a problem relating to IE that there seems to be virtually no documentation about on the 'Net - only a few people asking similar questions.

When I use jQuery (1.4.2) to send a POST request to my server (to which the server responds by sending JSON data), I occasionally get XHR 408 errors (meaning that the server timed out while waiting for the client to finish its request), and (less frequently), XHR 12152 errors (I don't know what these signify). There does not seem to be a pattern to this.

This only occurs in IE (version 8 - I haven't tried other versions, though I can confirm that the problem occurs on two different installations). Safari and Opera seem fine.

This doesn't seem to be a problem with GET requests.

If anyone has any thoughts on the matter, I'd be very grateful.

+1  A: 

When you see IE returning things in status that clearly aren't HTTP status codes, they're actually Windows error numbers, typically from WinInet.

12152 ERROR_HTTP_INVALID_SERVER_RESPONSE would seem to confirm the 408's implication that there's a low-level HTTP-syntax problem between your browser and the server. Traditionally this has been a problem with the ActiveX implementation of XMLHttpRequest and keep-alives in HTTPS, but the exact cause is rather murky.

You could perhaps try having the server set Connection: close on XMLHttpRequests that come from IE, see if that helps? This will affect performance, unfortunately.

bobince
I've just spent some time making sure that there's nothing in my code that could be responsible, and I'm inclined to think that - as you say - the issue resides with IE itself.As a total newbie when it comes to jQuery, can you give me any indicator of how I might go about issuing a 'Connection: close' as part of the POSTing process?
I think you can't set it on the request from XMLHttpRequest, but you should be able to set it on the response from the the server. You could sniff User-Agent on the server to set the header only for IE, but given the problems of server-side UA sniffing it might be better to detect IE from JS (eg. using a conditional comment) and pass a parameter like `?close=true` to tell the server to do it. I've not tried this myself, would be interested to see if it solves it. Personally what I get is very occasional closed socket errors in the logs, only ever from IE XMLHttpRequest.
bobince
I think that's solved it - I just sent a 'Connection: close' in the header from PHP. I've been running a JS script which POSTs every two seconds, and so far, it's not thrown any errors, where before, it would have done. I'll keep it running a bit longer, but I think you've just saved the last few months' work I've done; thank you!