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 shows that this code is

              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.