Search code examples
asp-classichttpsserverxmlhttp

ServerXMLHTTP Connection Issues


I'm trying to build a webpage in classic ASP to check the status of a series of URLs.

My code is as follows:

Function TestSite(sURL)

  UserAgent = "Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+5.1)"

  Set poster = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
  poster.open "GET", sURL, false
  poster.setRequestHeader "User-Agent",UserAgent
  poster.send

  If poster.status = 200 Then
    TestSite = poster.responseText
  Else
    ' ## ERROR ## '
    TestSite = ""
  End If
  Set poster = Nothing
End Function

The URLs are all HTTPS with non-standard port numbers included (eg https://somedomain.com:4433/restofurl)

When I run the urls in a web browser, they load just fine, but when I put them through the above function I get:

A connection with the server could not be established

I've checked my function with the following alternatives: 1) A non secure URL - this works fine 2) A secure URL with no port specified - this works fine 3) A secure URL specifying port 443 - this works fine 4) A secure URL specifying port 443 on the target server - THIS works fine

On the basis of that, I'm as sure as I can be that my code is correct. Does anyone have any suggestions for further troubleshooting?


Solution

  • The problem proved to be related to our server being old (still running Win2003) and their setup being even more non-standard than the port numbers suggest!

    The final solution was to host the code on some separate hosting (on a server running a more recent version of Windows). Not ideal, but at least we've got it working. (There is a server upgrade in our future, too - which will hopefully be the final solution.)