views:

9083

answers:

4

I have an HTA (microsoft html application - just an offline html + javascript app) that is using the standard MS XMLHTTP COM object (Microsoft.XMLHTTP or Msxml2.XMLHTTP depending on version detected) via JavaScript to send some data back to the server.

It is returning status code 0. This is apparently not a valid HTTP status code (they should be 3 digits according to the official but extremely vague spec). (BTW I tried unplugging the network connection and got status code 17003 or something, which I think from a lot of googling means "DNS server lookup failed".)

It works fine for me and some other people who have tested it from different locations. However, i have sent this over to the client who and they have recieved an HTTP status code of zero, and http responseText is blank. The client has tried it from two locations but both within their corporate network.

This is an HTTP POST to an HTTP URL on the internet (not a file:// request which i understand also would return status code 0 for success under mozilla). I'm pretty sure this is a failure code as it should return some confirmation as the responseText, and we are not getting the data recorded in the database.

+2  A: 

wininet.dll returns standard && non-standard status codes that are listed below.

401 - Unauthorized file
403 - Forbidden file
404 - File Not Found
500 - some inclusion or functions may missed
200 - Completed

12002 - Server timeout
12029,12030, 12031 - dropped connections (either web server or DB server)
12152 - Connection closed by server.
13030 - StatusText properties are unavailable, and a query attempt throws an exception

For the status code "zero" are you trying to do a request on a local webpage running on a webserver or without a webserver ?

here's a link that can help you if you are not running your script on a webserver.

SleepyCod
Thanks for the codes. No, it is not a local request, it is a request to a web server on the internet, from a locally running vbscript.
mike nelson
+3  A: 

I believe the error code indicates that the response was empty, (as not even headers were returned). This means the connection was accepted and then closed gracefully (TCP FIN). There are a number of things which could cause this, but based off of your description, some form of firewall seems the most likely culprit.

Nick
I think you are probably right. (Although, as pointed out by @sleepycod wininet.dll would be expected to return some status code in the absence of a _real_ http status code.)
mike nelson
+1  A: 

Workaround: what we ended up doing

We figured it was to do with firewall issues, and so we came up with a workaround that did the trick. If anyone has this same issue, here's what we did:

  1. We still write the data to a text file on the local hard disk as we previously did, using an HTA.

  2. When the user clicks "send data back to server", the HTA reads in the data and writes out an HTML page that includes that data as an XML data island (actually using a SCRIPT LANGUAGE=XML script block).

  3. The HTA launches a link to the HTML page in the browser.

  4. The HTML page now contains the javascript that posts the data to the server (using Microsoft.XMLHTTP).

Hope this helps anyone with a similar requirement. In this case it was a Flash game used on a laptop at tradeshows. We never had access to the laptop and could only email it to the client as this tradeshow was happening in another country.

mike nelson
A: 

For what it is worth, depending on the browser, jQuery-based AJAX calls will call your success callback with a HTTP status code of 0. We've found a status code of "0" usually means the user navigated to a different page before the AJAX call completed.

Not the same technology stack as you are using, but hopefully useful to somebody.

Cory R. King