wildtangent
asked on
Timeout problems and general unreliability using msxml
Hi all,
This is turning into a real annoyance. I am trying to use MSXML server objects to load ASP pages into my website template. This works about 80% of the time, really fast and efficient, but the other 20%, the script just times out. I'm connecting to a page within the same web server, so there shouldn't really be any network traffic issues. I've tried with MSXML2.ServerXMLHTTP v 2, 3, 4, and 6 and they all suffer the same unreliability.
I'm using these server side (obviously). I reckon the problem sort of lies with the While....Wend statement but don't really know how to fix it.
My Script is below, though because it is part of a bigger class, some of the variables etc may not be obvious. Need all the stuff to do with cookies and referers due to login post-thru requirements.
Hope you can help!!
Public Sub GetXMLHTTP(vDoc, vType)
Dim oXMLHTTP, vReferer, vHTTP
Set oXMLHTTP = Server.CreateObject("MSXML 2.ServerXM LHTTP.6.0" )
If Request.ServerVariables("H TTPS") = "on" Then vHTTP = "https://" : Else vHTTP = "http://"
vReferer = vHTTP & Request.ServerVariables("H TTP_HOST") & Request.ServerVariables("S CRIPT_NAME ") & "?" & Request.QueryString
If len(pCookies) = 0 Then pCookies = "nothing=nothing"
If CheckTextRequest(pPost) Then pFormPost = pFormPost & pPost
If CheckTextRequest(CStr(Requ est.Form)) Then pFormPost = pFormPost & CStr(Request.Form)
Err.Clear()
oXMLHTTP.Open "POST", vDoc, False
oXMLHTTP.SetRequestHeader( "Cookie") = "nothing=nothing"
oXMLHTTP.SetRequestHeader( "Cookie") = pCookies
If CheckTextRequest(pFormPost ) Then
oXMLHTTP.SetRequestHeader "Content-Type", "application/x-www-form-ur lencoded"
oXMLHTTP.SetRequestHeader "Referer", vReferer
oXMLHTTP.Send CStr(pFormPost)
Else
oXMLHTTP.Send
End If
While oXMLHTTP.ReadyState <> 4
oXMLHTTP.WaitForResponse 1000
Wend
Dim strHeaders, hArr
strHeaders = oXMLHTTP.getAllResponseHea ders()
hArr = split(strHeaders,"Set-Cook ie: ")
For kk = 1 to ubound(hArr)
theCookie = left(hArr(kk),instr(hArr(k k),"path=/ ")-2)
pCookies = pCookies & " " & theCookie
Next
Select Case vType
Case 1 Set oXMLDoc = oXMLHTTP.ResponseXML
Case 2 oXMLDocText = replace(oXMLHTTP.responset ext,"../", baseURL)
Case Else Set oXMLDoc = oXMLHTTP.ResponseXML
oXMLDocText = replace(oXMLHTTP.responset ext,"../", baseURL)
End Select
Set oXMLHTTP = Nothing
End Sub
This is turning into a real annoyance. I am trying to use MSXML server objects to load ASP pages into my website template. This works about 80% of the time, really fast and efficient, but the other 20%, the script just times out. I'm connecting to a page within the same web server, so there shouldn't really be any network traffic issues. I've tried with MSXML2.ServerXMLHTTP v 2, 3, 4, and 6 and they all suffer the same unreliability.
I'm using these server side (obviously). I reckon the problem sort of lies with the While....Wend statement but don't really know how to fix it.
My Script is below, though because it is part of a bigger class, some of the variables etc may not be obvious. Need all the stuff to do with cookies and referers due to login post-thru requirements.
Hope you can help!!
Public Sub GetXMLHTTP(vDoc, vType)
Dim oXMLHTTP, vReferer, vHTTP
Set oXMLHTTP = Server.CreateObject("MSXML
If Request.ServerVariables("H
vReferer = vHTTP & Request.ServerVariables("H
If len(pCookies) = 0 Then pCookies = "nothing=nothing"
If CheckTextRequest(pPost) Then pFormPost = pFormPost & pPost
If CheckTextRequest(CStr(Requ
Err.Clear()
oXMLHTTP.Open "POST", vDoc, False
oXMLHTTP.SetRequestHeader(
oXMLHTTP.SetRequestHeader(
If CheckTextRequest(pFormPost
oXMLHTTP.SetRequestHeader "Content-Type", "application/x-www-form-ur
oXMLHTTP.SetRequestHeader "Referer", vReferer
oXMLHTTP.Send CStr(pFormPost)
Else
oXMLHTTP.Send
End If
While oXMLHTTP.ReadyState <> 4
oXMLHTTP.WaitForResponse 1000
Wend
Dim strHeaders, hArr
strHeaders = oXMLHTTP.getAllResponseHea
hArr = split(strHeaders,"Set-Cook
For kk = 1 to ubound(hArr)
theCookie = left(hArr(kk),instr(hArr(k
pCookies = pCookies & " " & theCookie
Next
Select Case vType
Case 1 Set oXMLDoc = oXMLHTTP.ResponseXML
Case 2 oXMLDocText = replace(oXMLHTTP.responset
Case Else Set oXMLDoc = oXMLHTTP.ResponseXML
oXMLDocText = replace(oXMLHTTP.responset
End Select
Set oXMLHTTP = Nothing
End Sub
ASKER
Hi, I've tried both of those options but it doesn't seem to make a lot of difference. The errors occur pretty inconclusively randomly, though seem to be less frequent with msxml6 installed.
Cheers tho, any more suggestions?
Cheers tho, any more suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
looks good, will try tomorrow. Thanks!
oXMLHTTP.Open "POST", vDoc, False
To
oXMLHTTP.Open "POST", vDoc, True