Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to detect Server or Networking failures when using XMLHTTP


View products that this article applies to.

Summary

When you use XMLHTTP requests to receive data from a webserver, the requests may be acknowledged by the server at the TCP-level, but then aborted by the server without delivering the HTTP response. In this scenario, the web application may need to handle this behavior in order to proceed by using a retry operation or other similar error handling.

This can be achieved by checking the variable status within the callback function onreadystatechange. For example, in a case where the XMLHTTP call is not successful this status will have the value 12152, which is equivalent to ERROR_HTTP_INVALID_SERVER_RESPONSE. The readystate itself is already set to 4 (READYSTATE_COMPLETE).

The sample for the onreadystatechange event documented in MSDN (see the More Information section below) checks for the status codes 200 (OK) or 304 (Not modified), and interprets these status codes as successful. Any other HTTP status code is considered to be an error condition, which will include the status 12152.

When using the HTTP POST method in the XMLHTTP request, be aware of the limitations that are described in the following Knowledge Base article:

When you use Internet Explorer or another program to perform a re-POST operation, only the header data is posted


Specifically, note that when a re-POST has been initiated only the HTTP-headers are sent, and the data which should have been POSTed is not sent again. Since the HTTP headers of the POST request will typically include a Content-Length header indicating the size of the POST data, the server will have to wait for the data until a timeout has been triggered, which will usually result in an HTTP 500 (Server error) response from the webserver.

When you enable the hotfix from KB895954 by creating the FeatureControl key FEATURE_SKIP_POST_RETRY_ON_INTERNETWRITEFILE_KB895954, the incomplete re-POST will not occur and the status 12152 will be reported as the status to the XMLHTTP object. Therefore you may consider performing a retry of the request through script.

↑ Back to the top


More Information

895954 When you use Internet Explorer or another program to perform a re-POST operation, only the header data is posted
http://support.microsoft.com/kb/895954/EN-US

Description of the onreadystatechange event
http://msdn.microsoft.com/en-us/library/ie/dd576252(v=vs.85).aspx

193625 INFO: WinInet Error Codes (12001 through 12156)
http://support.microsoft.com/kb/193625


↑ Back to the top


Keywords: kb

↑ Back to the top

Article Info
Article ID : 2826958
Revision : 1
Created on : 1/7/2017
Published on : 3/22/2013
Exists online : False
Views : 378