通过经典asp中的Vb脚本从错误/超时开始执行函数
我的 create.asp
页面中有以下方法:
Public Function read(url)
Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xmlHttp.Open "GET", url, False, PROXY_USERNAME, PROXY_PASSWORD
xmlHttp.SetProxy 2, PROXY
xmlHttp.SetTimeouts 0, 0, 0, 0
xmlHttp.Send
xml.Async = False
xml.SetProperty "ServerHTTPRequest", True
xml.ValidateOnParse = True
xml.Load xmlHttp.ResponseXml
Set read = xml
Set xmlHttp = Nothing
Set xml = Nothing
End Function
该函数 10 次中有 9 次有效。
问题:在极少数情况下,它会给我一个超时错误。因此,我将 xmlHttp.Timeouts 设置为无穷大。我也尝试过使用 On error
语句,但这并不能解决问题。
问题:*如果函数出现任何类型的错误,我该如何从头开始执行该函数? *我遇到的唯一错误是尝试执行xmlHttp.Send
时出现超时错误。
任何其他可能的解决方案也将受到赞赏。
I have the following method in my create.asp
page:
Public Function read(url)
Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xmlHttp.Open "GET", url, False, PROXY_USERNAME, PROXY_PASSWORD
xmlHttp.SetProxy 2, PROXY
xmlHttp.SetTimeouts 0, 0, 0, 0
xmlHttp.Send
xml.Async = False
xml.SetProperty "ServerHTTPRequest", True
xml.ValidateOnParse = True
xml.Load xmlHttp.ResponseXml
Set read = xml
Set xmlHttp = Nothing
Set xml = Nothing
End Function
The function works 9 times out of 10.
Problem: In rare occasions, it gives me a timeout error. For this reason, I have set xmlHttp.Timeouts
to infinity. I have also tried using On error
statements, but that does not resolve the issue.
Question: *How do I execute the function from the start if it gives me any kind of error? * The only error I have come across is the timeout error when it tries to execute xmlHttp.Send
.
Any other possible solution would also be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与其说是代码问题,不如说是代理服务器问题。
如果您希望能够重试,您可以;
Rather than a code problem, its most likely an issue with the proxy server.
If you want to be able to retry you can;