Friday, April 13, 2007

IE6 and error code 12030

If you are running Internet Explorer 6 and using Ajax, you may get some XMLHttpRequests terminated with code 12030.

Microsoft's knowledge base at http://support.microsoft.com/kb/193625 shows that this code is

  12030       ERROR_INTERNET_CONNECTION_ABORTED
              The connection with the server has been terminated.

Googling turned up no help; the people encountering this don't seem to be aware of how network sockets work, so I had to actually figure it out on my own.

This happens when the client thinks a connection has been kept open, and the server thniks it is closed. The server has sent a FIN, and the client has responded to that with an ACK. Running "netstat" on the Windows client shows that the connection is in the CLOSE_WAIT state, so IE6 really *ought* to have realized this before trying. This is entirely the client's fault. If you wait about 60 seconds, the Windows OS stack will retire the connection.

If you need to support IE6, you have some solutions, in various degrees of ugly:

  • retry the ajax request in case of error code 12030
  • if the browser is ie, send an empty request to the server ahead of each ajax request
  • bundle up your ajax requests such that the time between them is ( (greater than server_timeout) AND (less than server_timeout + one minute)

IE7, fwiw, will issue a RST over the CLOSE_WAIT socket as soon as it realizes it has an outgoing connection to make. That, and the socket will only stay in that CLOSE_WAIT state for about 5 seconds anyway.

12 comments:

  1. Anonymous8:55 AM

    Fails a lot on IE7 too (seems to be getting worse if that is possible) - watched it happen after socket went to TIME_WAIT then disappeared. Needed delay of ~15 mins on Windows.

    As you say, best to retry in the onreadystatechange callback - this seems to work well.

    ReplyDelete
  2. Anonymous6:49 AM

    I agree fully that this is entirely the clients fault and this explains why sometimes the first request seemed to work and then subsequent requests using exactly the same data, fails.

    FYI, happens most using POST requests and SSL.

    All is not lost however, I have recently experimented and found a possible cure. You must ensure the header name/pair variables are set correctly before submitting the request, doing that causes IE6 (and IE7) to handle the request correctly and closes cleanly.

    No more 12030 errors for me :-)

    ReplyDelete
  3. Hello,

    There is a solution at the bottom of that page : http://www.developpez.net/forums/showthread.php?t=306474

    Cheers

    ReplyDelete
  4. Anonymous12:59 PM

    I have a question about this problem. Did you ever find a good fix for it?? We seem to be having the same problem by simply adding an updatePanel control to our page. The Page uses a lot of ViewState variables and it works fine from local machine but as soon as we upload it to server.... we start getting the server errors 12030 Or 12029.

    ReplyDelete
  5. Anonymous5:54 AM

    Interesting to know.

    ReplyDelete
  6. Anonymous5:49 PM

    In the rare chance someone stumbles across this blog post and is using extjs, i was sending 3 http-post requests before initializing a grid (to get fk information) and was fairly reliably getting 12030 back (had to investigate ext-base.js to find this actual error though)
    Changing requests to get fixed the problem, changing requests to be chained improved the problem.
    In my case, header name/pair variables seemed to be set correctly, but there weren't many of them.

    ReplyDelete
  7. Excellent. Changing it to GET worked great. Exactly what should have jumped out when I looked at my function. I was getting data back so it makes sense.

    ReplyDelete
  8. Anonymous2:17 AM

    I've the same problem, but in a different context.

    I develope in local on Xp-Pro (i.e. http://localhost/mysite) and usually my pc is connected on LAN; in this situation I've never got any problem, but if disconnect my pc from the network, I got error 12030 o 12152. Reading your post I've identified that is a connection problem.
    My Ajax routine was

    ajax.open("get", req, true);

    // rimozione dell'header "connection" come "keep alive"
    ajax.setRequestHeader("connection", "close");

    and it was simply comment the last line ajax.setRequestHeader to resolve my problem.

    tanks everyone.
    By

    Carlo

    ReplyDelete
  9. Anonymous9:48 PM

    This happens in IE8 too, after starting the system after a os hibernation.

    ReplyDelete
  10. Anonymous5:22 PM

    I was having the same problem, and, as the poster above said, changing the POST to a GET request seemed to resolve the issue.

    Thank you much,
    Eric

    ReplyDelete
  11. Hi, Can anyone please give me pointers to some sample code on this.
    I am using the asp.net ajax toolkit for dot net version 3.5 and i'm getting this 12030 error on IE6. Some sample code on how to send a blank request everytime a ajax request is made.

    Thank you.

    ReplyDelete
  12. One cause for this error is the path to your ajax method is wrong. Check that out first. You'd be surprised at how easy it is to overlook the simple things. Especially double check this if you made changes to the variables that build the ajax path. The same thing happened to me and I got the same error.

    ReplyDelete