Answered by:
Server returned invalid or unrecognized response

Question
-
Hi there,
I'm customizing an off-the-shelf application consisting of default html template files as a classic ASP application. My code uses MSXML, which was working fine in a Windows Server 2003/iis6 environment, but once we transitioned to Windows Server 2008/iis 7, the following error has been occurring frequently:
Error number: -2147012744, Error description: The server returned an invalid or unrecognized response , Error source: msxml3.dll
While we did see this error in our Dev environment with Win server 2003/iis 6, it didn't happen very often and I added some code to handle it. In the new environment in Prod, it's occurring way too often and the handling code is useless there. We have tried a variety of things, including upgrading to MSXML4 SP3, putting <httpWebRequest useUnsafeHeaderParsing="true" /> in a web.config file, playing around with the setTimeout methods, etc. Nothing we tried has worked. One thing I noticed is that when this error occurs, the serverXmlHttp readyState property stays at 1. The definition for that readyState value is: (1) LOADING The object has been created but the send method has not been called. For some reason it's as though the Send method doesn't get called.
Here is my code. Any insight would be appreciated.
'//Set up SOAP object:
Set xmlHttp = Server.CreateObjec("MSXML2.ServerXMLHTTP.3.0")
xmlHttp.Open "GET", destUrl, false
xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlHttp.setOption 2,SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
'//Send SOAP request and determine if error occurred:
Dim blnError
blnError = false
On Error Resume Next
xmlHttp.Send()
Response.Write xmlHttp.readyState
If (Err.Number <> 0) Then
blnError = true
'//Loop below is to resolve random invalid/unrecognized response server error. Loop iterates until error is gone or 4 times max,
'//after which point code execution continues normally, or the remaining/other error is handled
For count = 0 to 3
If (Err.Number = -2147012744 OR Err.Number = -2147012894) Then
'//i.e. random error "server returned an invalid or unrecognized response"
On Error Resume Next
xmlHttp.Open "GET", destUrl, false
xmlHttp.Send()
Response.Write xmlHttp.readyState
Else
Exit For
End If
Next
If (Err.Number <> 0) Then
errMsg = "Error number: " & Err.Number & ", Error description: " & Err.Description & ", Error source: " & Err.Source
Err.Number = 0
Else
blnError = false
End If
End If
If (blnError = false) Then
'//If status is 200 then request succeeded, so display search results:
If (xmlHttp.status = 200) Then
RsltsXML = xmlHttp.ResponseText
Response.Write(RsltsXML)
Else
blnError = true
errMsg = Error number:" & xmlHttp.status & ",Error description:" & xmlHttp.statusText & ",Details: " & xmlHttp.ResponseText
End If
End If
Set xmlHttp = Nothing '//clear HTTP object
If (blnError = true) Then
'//Handle any error that occurred by sending an email and redirecting to generic error screen
End If
- Edited by devOneTwoThree Monday, October 17, 2011 12:51 PM
- Moved by Alan_chen Thursday, October 20, 2011 2:10 AM IIS (From:XML, System.Xml, MSXML and XmlLite)
Monday, October 17, 2011 12:43 PM
Answers
-
Well Google Chrome's developer tool shows you the traffic between the browser and your classic ASP app but if that app makes another connection to a different server then of course the browser is not able to monitor that traffic of the connection between the two servers. I am not sure what to do here in the forum to solve that problem, in your original post you said the problem occurs more often after switching to IIS 7 so maybe someone in http://forums.iis.net/1044.aspx is able to help.
Yes, using Google Chrome I hit my app a number of times and get the error. Even when the error occurs, the developer toolbar doesn't indicate that anything is wrong. The response header appears normal.
One detail I omitted is that the URL I pass to the serverXmlHttp object is essentlally a search command and references an assembly/dll in order to retrieve search results through the off-the-shelf product we're using. Perhaps that could be the source of the problem, but it's odd that this error seems to occur randomly and not all the time.
MVP Data Platform Development My blog- Proposed as answer by Ed Price - MSFTMicrosoft employee Sunday, October 30, 2011 9:40 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 16, 2011 10:40 PM
Tuesday, October 18, 2011 10:47 AM
All replies
-
Why do you make a HTTP GET request but then set
xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
? That does not make sense to me, a HTTP GET request has no request body so indicating a Content-Type is meaningless.
Whether that has anything to do with your error I don't know.
As for your attempts to work around the problem, have you tried to use MSXML 6 instead of MSXML 3 (i.e. by doing
Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
)?
What kind of server are you sending the request to? Have you tried a network sniffer (like wireshark) to find out what response is sent when MSXML complains about it being invalid?
MVP Data Platform Development My blogMonday, October 17, 2011 1:23 PM -
Hi Martin,
Thanks for your reply.
I think the setRequestHeader call for setting the Content-Type was added when I was trying various things to resolve a special character problem. It may not be needed, but removing it doesn't fix the error I'm getting now (The server returned an invalid or unrecognized response ).
I have tried both MSXML 4 and MSXML 6 instead of version 3, and none of those made a difference.
The request is being sent to a server configured with Windows Server 2008 and IIS 7. It's a virtual server, and I don't have any access to it. I've been told that I can't install network sniffing tools although I think they could probably help. I tried using Google Chrome's developer tools, but it it tells me that response headers returned with HTTP/1.1 200 OK.
Monday, October 17, 2011 2:24 PM -
Do you get that error for each request your classic ASP code makes to the server? Or just sometimes?
MVP Data Platform Development My blogMonday, October 17, 2011 4:27 PM -
The error occurs only sometimes. And when it happens, the serverXmlHttp object's readyState property stays at 1, even though the send method was called.
I've read in some places that the error could be caused if there's more than one header in the response or by the data returned somehow getting truncated. Is there some way that I check for that?
Monday, October 17, 2011 4:43 PM -
The error occurs only sometimes. And when it happens, the serverXmlHttp object's readyState property stays at 1, even though the send method was called.
I've read in some places that the error could be caused if there's more than one header in the response or by the data returned somehow getting truncated. Is there some way that I check for that?
A network sniffer should show what the server sends but if you can't install that on your client I am not sure what to suggest. There is a method getAllResponseHeaders on MSXML's (Server)XMLHTTP object so you could try to check its output but I am not sure it will return something if the readyState is staying at 1 and MSXML reports an invalid response.As you said with Google Chrome you don't get an error, have you tried that as often as your ASP app hits the server to encounter the error?
MVP Data Platform Development My blogMonday, October 17, 2011 5:29 PM -
Thanks for the reply again.
I tried calling getAllResponseHeaders before, but like you said, it doesn't work due to the readyState remaining at 1. The call causes a new error, "The handle is in the wrong state for the requested operation " because of this.
Yes, using Google Chrome I hit my app a number of times and get the error. Even when the error occurs, the developer toolbar doesn't indicate that anything is wrong. The response header appears normal.
One detail I omitted is that the URL I pass to the serverXmlHttp object is essentlally a search command and references an assembly/dll in order to retrieve search results through the off-the-shelf product we're using. Perhaps that could be the source of the problem, but it's odd that this error seems to occur randomly and not all the time.
Monday, October 17, 2011 6:53 PM -
Well Google Chrome's developer tool shows you the traffic between the browser and your classic ASP app but if that app makes another connection to a different server then of course the browser is not able to monitor that traffic of the connection between the two servers. I am not sure what to do here in the forum to solve that problem, in your original post you said the problem occurs more often after switching to IIS 7 so maybe someone in http://forums.iis.net/1044.aspx is able to help.
Yes, using Google Chrome I hit my app a number of times and get the error. Even when the error occurs, the developer toolbar doesn't indicate that anything is wrong. The response header appears normal.
One detail I omitted is that the URL I pass to the serverXmlHttp object is essentlally a search command and references an assembly/dll in order to retrieve search results through the off-the-shelf product we're using. Perhaps that could be the source of the problem, but it's odd that this error seems to occur randomly and not all the time.
MVP Data Platform Development My blog- Proposed as answer by Ed Price - MSFTMicrosoft employee Sunday, October 30, 2011 9:40 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 16, 2011 10:40 PM
Tuesday, October 18, 2011 10:47 AM -
Thanks for your assistance Martin. I've posted my question in that forum. I can provide an update here if I figure anything out.
Tuesday, October 18, 2011 4:17 PM