Httpsendrequest

I have an agent that uses a script library function to access a notes view via the http service. This function updates a counter for each transmission that comes in to our system. When one server is down (http isn’t responding) we want failover to one of the named servers in our list. Problem is, we cannot predict what will come back from the HTTPSENDREQUEST call. Is there a fix to this problem. I saw reference to a similar problem in the 4 and 5 forum. My code follows:

Class ControlNumber

Private thisHost (2) As String

Private thisUser (2) As String

Private thisPassword (2) As String

Private thisSSL (2) As Integer



Property Set Internal As Integer

	If Me.Internal Then

		thisHost (0) ="storm"

		thisUser (0) = ""

		thisPassword (0) = ""

		thisSSL (0) = False

		thisHost (1) ="gambit"

		thisUser (1) = ""

		thisPassword (1) = ""

		thisSSL (1) = False

		thisHost (2) =""

		thisUser (2) = ""

		thisPassword (2) = ""

		thisSSL (2) = False

	Else

		thisHost (0) ="WEXAPT03"

		thisUser (0) = ""

		thisPassword (0) = ""

		thisSSL (0) = False

		thisHost (1) = "wexapd04"

		thisUser (1) = ""

		thisPassword (1) = ""

		thisSSL (1) = False

		thisHost (2) ="WEXAPT02"

		thisUser (2) = ""

		thisPassword (2) = ""

		thisSSL (2) = False

	End If

End Property



Function Next (account As String, controlType As String) As Long

	Dim http As Http

	Dim httpRequest As HttpRequest

	Dim url As String

	Dim port As Integer

	Dim flags As Long

	Dim i As Integer

	

	Me.Next = -1

	flags = INTERNET_FLAG_NO_CACHE_WRITE Or INTERNET_FLAG_RELOAD

	For i = 0 To Ubound (thisHost)

		If thisSSL (i) Then

			port = INTERNET_DEFAULT_HTTPS_PORT

			flags = flags Or INTERNET_FLAG_SECURE Or INTERNET_FLAG_IGNORE_CERT_CN_INVALID

		Else

			port = INTERNET_DEFAULT_HTTP_PORT

		End If

		Set http = New Http (thisHost (i), thisUser (i), thisPassword (i), port, 0, "GetNextControl", INTERNET_OPEN_TYPE_DIRECT, "", "", 0)

		url = "/controlnumber.nsf/next?open&account=" & Lcase(account) & "&type=" & Lcase(controlType)

		Set httpRequest = http.OpenRequest(url, "GET", "", "", "", flags)

’ Test to see if there is an HTTP failure on the server. If so, try the next server in the list. If successful, exit.

		If httpRequest.SendRequest("") Then

			Me.Next = Clng(Val(httpRequest.ReadData))			

			Print "success on " & thisHost(i)

			Exit For

		Else

			Print "failure on " & thisHost(i)

		End If

	Next i

End Function



Sub New

	Me.Internal = False

End Sub

End Class