I use the following function to check if a RSS url is healthy then consume it:
function testUrl(url)
testUrl=0
Set o = CreateObject("MSXML2.XMLHTTP")
on error resume next
o.open "GET", url, false
o.send
if o.Status = 200 then testUrl = 1
on error goto 0
set o=nothing
end function
However when the target URL does not respond in a short time I will get timeout error. So I want to use the following function in this Q/A to terminate the request after 5 seconds if there was no success response but I dont know where to put the asp_Wait(5) and how to cancel the request after 5 seconds? Should I put asp_Wait right after the o.send
or o.send
acts synchronous?
Function asp_Wait(nMilliseconds)
Dim oShell
Set oShell= Server.CreateObject("WScript.Shell")
Call oShell.run("ping 1.1.1.1 -n 1 -w " & nMilliseconds,1,TRUE)
End Function
question from:
https://stackoverflow.com/questions/65865738/where-to-put-the-sleep-function-in-msxml-request 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…