Link to home
Start Free TrialLog in
Avatar of wildtangent
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("MSXML2.ServerXMLHTTP.6.0")
      If Request.ServerVariables("HTTPS") = "on" Then vHTTP = "https://" : Else vHTTP = "http://"

      vReferer = vHTTP & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME") & "?" & Request.QueryString
      If len(pCookies) = 0 Then pCookies = "nothing=nothing"

      If CheckTextRequest(pPost) Then pFormPost = pFormPost & pPost
      If CheckTextRequest(CStr(Request.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-urlencoded"
                  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.getAllResponseHeaders()

    hArr = split(strHeaders,"Set-Cookie: ")
      For kk = 1 to ubound(hArr)  
          theCookie = left(hArr(kk),instr(hArr(kk),"path=/")-2)  
          pCookies = pCookies & " " & theCookie
      Next
      
      Select Case vType
            Case 1            Set oXMLDoc = oXMLHTTP.ResponseXML
            Case 2            oXMLDocText = replace(oXMLHTTP.responsetext,"../",baseURL)
            Case Else      Set oXMLDoc = oXMLHTTP.ResponseXML
                              oXMLDocText = replace(oXMLHTTP.responsetext,"../",baseURL)
      End Select
      Set oXMLHTTP = Nothing
End Sub

Avatar of CyrexCore2k
CyrexCore2k
Flag of United States of America image

Change This:

oXMLHTTP.Open "POST", vDoc, False

To

oXMLHTTP.Open "POST", vDoc, True
Avatar of wildtangent
wildtangent

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?
ASKER CERTIFIED SOLUTION
Avatar of CyrexCore2k
CyrexCore2k
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
looks good, will try tomorrow. Thanks!