Link to home
Start Free TrialLog in
Avatar of sachitjain
sachitjainFlag for India

asked on

Status of XMLHTTPRequest object is 12031 on call of its Send method

I have a JS function that takes input parameters as URL and some input XML, it then instantiates an object (xmlhttp) of type "MSXML2.XMLHTTP.6.0" and calls its Send method with given input parameters. Most of the times function runs well but sometimes it gives status of object as 12031 instead of 200. Any clues why this error is occuring and what could be the possible remediation to handle it or avoid it?

function SendXmlHttp(sURL, sSendXml)
{
	try
	{
		var xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.6.0");

		// cursory check of the XML - make sure it has an XML declaration
		var lsXml = checkXmlBeforeSend(sSendXml);
	
		xmlhttp.Open("POST", sURL, false);
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlhttp.send(lsXml);
                                           ......................
Avatar of Badotz
Badotz
Flag of United States of America image

Try using the XHR objects as follows:

var xmlhttp = getXmlHttp(); // Get the proper XHR object for all browsers
function getXmlHttp() {
    var x = [
        function() { return new XMLHttpRequest(); },
        function() { return new ActiveXObject("Msxml2.XMLHTTP"); },
        function() { return new ActiveXObject("Microsoft.XMLHTTP"); }
    ];
    for (var i = 0; i < x.length; i += 1) {
        try { var f = x[i], r = f(); if (r !== null) { return r; } }
        catch(e) { continue; }
    }
    return null;
}

Open in new window

Avatar of sachitjain

ASKER

Badotz

Thanks for inputs but unfortunately these did not help! :-(

Actually we are migrating one ASP application to ASP.Net and this is JS portion on one common JS file. In it URL parameter now is .ASPX not .ASP. With .ASP URLs this function never returns any such exception.
SOLUTION
Avatar of Badotz
Badotz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Found this:


/*

IE status Property Value    Corresponding statusText Value

12002                       ERROR_INTERNET_TIMEOUT
12007                       ERROR_INTERNET_NAME_NOT_RESOLVED
12029                       ERROR_INTERNET_CANNOT_CONNECT
12030                       ERROR_INTERNET_CONNECTION_ABORTED
12031                       ERROR_INTERNET_CONNECTION_RESET
12152                       ERROR_HTTP_INVALID_SERVER_RESPONSE

*/

Open in new window

I am using IE6 only. Interestingly ASP application with same browser never gives any such exception in same JS code but migrated ASP.Net application gives this exception seldom with same JS code.

I already found status text against this status code 12031 but not root cause or fix unfortunately. :-(
The only clue here is "ERROR_INTERNET_CONNECTION_RESET" - perhaps your server is flaking?
SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do you use a wi-fi connexion ?
Open command line and run a ping to your server (update server_adress with your server address) :
ping server_adress -n 1000000

Open in new window

leakim971
Its not Wi-fi connection.

gurvinder372:
Thanks for sharing these links. Actually the scenario is link a page is there that populates the list of pending of notifications of user and refreshes itself periodically by sending an asynchronous request to an ASPX page. The ASPX page in turn would call COM+ services to fetch latest list of notifications from the server and post it back to client. I am suspecting that irregular behavior by COM+ services might also cause connection reset to client but don't have enough evidence to prove it. As suggested in your first link, I don't think size of response is an issue here because 8 out of 10 times the notification page refreshes perfectly. It causes issues for hardly 2 of the 10 times.

I would keep you guys posted with my findings but please provide any other pointer if you think like I might be missing in my analysis.
>Its not Wi-fi connection.
OK, run the ping and browse the site, it may help you to know if you've a connexion problem with the server.
Which is what I suggested in http:#a4523087...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks
No worries - glad to help.