8

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.

narnianUK
  • 91
  • 1
  • 1
  • 3
  • I believe 12152 is something like "the server has been taken down momentarily for database or server maintenance, or there has been a network error." So, timeout, essentially. – Robert Sep 16 '10 at 22:50
  • Given that you're getting two timeout errors, have you tried extending the timeout time? – Robert Sep 16 '10 at 22:53
  • Occurs in IE9 also. Error 12152 and error 12031. Does seem to occur with AJAX requests, and so far unpredictably. – nothingisnecessary Jul 01 '15 at 18:55

2 Answers2

8

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
  • 528,062
  • 107
  • 651
  • 834
  • 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? – narnianUK Sep 17 '10 at 09:51
  • 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 Sep 17 '10 at 10:23
  • 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! – narnianUK Sep 17 '10 at 11:01
  • the Connection: close response header seems to work but it keeps failing sometime (error 12002). Do you have more thoughts on this? – ramon_salla Dec 13 '11 at 13:59
  • @ramon_salla your [request timed out](https://learn.microsoft.com/fr-fr/windows/desktop/WinInet/wininet-errors#error_internet_timeout). – Knu Jan 29 '19 at 19:28
3

I solved it by adding "Connection: close" to ajax header also.

There is no need to add "Connection: close" to the response header from the server.

I have tested firing 1,000 requests.

Tanin
  • 31
  • 1
  • 1
    I take my words back. You need connection:close on the server side also. – Tanin Feb 16 '11 at 08:51
  • how do you add connection close to the request? Connection is one info that is not possible to change according w3c the browser is responsible to set it. I tried to change manually and ins't work. – Weslley Wellington Dec 05 '14 at 14:02