gpt4 book ai didi

Excel HTTP 获取超时

转载 作者:行者123 更新时间:2023-12-02 09:42:28 25 4
gpt4 key购买 nike

我们有一个小子,它可以将数据简单地泵入远程服务器。一切都按预期进行。

前几天,网络服务器发生了一次持续大约一个小时的事件。我仍然可以 PING 服务器,但 IIS 没有响应。结果,宏只是挂起等待响应。

对快速通过/失败测试或超时有什么想法吗?

Sub WebLog(getUser As String, getEvent As String, getValue As String)
Dim URL As String
URL = "http://myurl.com/dp.aspx?Task=Log&v1=" + getUser + "&v2=" + getEvent + "&v3=" + getValue
Dim xml As Object
Set xml = CreateObject("MSXML2.XMLHTTP")
xml.Open "GET", URL, False
xml.Send
End Sub

最佳答案

您可能需要查看 WinHttp.WinHttpRequest.5.1 库,它允许您为请求设置超时

WinHttpRequest object

您应该在.Open之前设置.SetTimeouts,并且为.SetTimeouts设置的四个参数是(以毫秒为单位):

Resolve, Connect, Send and Receive

您的示例代码为(10 秒超时):

Sub WebLog(getUser As String, getEvent As String, getValue As String)
Dim URL As String
URL = "http://myurl.com/dp.aspx?Task=Log&v1=" + getUser + "&v2=" + getEvent + "&v3=" + getValue
Dim xml As Object
Set xml = CreateObject("WinHttp.WinHttpRequest.5.1")
xml.SetTimeouts 10000, 10000, 10000, 10000
xml.Open "GET", URL, False
xml.Send
End Sub

关于Excel HTTP 获取超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49826217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com