检查是否其他Web服务器正在从ASP侦听
时间:2020-03-06 14:20:35 来源:igfitidea点击:
我正在使用Microsoft.XMLHTTP从旧的ASP / VBScript站点从另一台服务器获取一些信息。但是该另一台服务器经常重启,因此我想在尝试从中获取信息之前检查它是否已启动并正在运行(或者通过其他方式检测到该问题,从而避免我的页面提供HTTP 500)。
如何使用ASP做到这一点?
解决方案
我们可以尝试对服务器执行ping操作并检查响应。
看一下这篇文章。
我们需要做的就是让代码继续在错误中继续,然后将其发布到其他服务器上并从该帖子中读取状态。像这样的东西:
PostURL = homelink & "CustID.aspx?SearchFlag=PO" set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.3.0")
错误返回下一个
xmlhttp.open "POST", PostURL, false xmlhttp.send ""
状态= xmlhttp.status
if err.number <> 0 or status <> 200 then if status = 404 then Response.Write "ERROR: Page does not exist (404).<BR><BR>" elseif status >= 401 and status < 402 then Response.Write "ERROR: Access denied (401).<BR><BR>" elseif status >= 500 and status <= 600 then Response.Write "ERROR: 500 Internal Server Error on remote site.<BR><BR>" else Response.write "ERROR: Server is down or does not exist.<BR><BR>" end if else 'Response.Write "Server is up and URL is available.<BR><BR>" getcustomXML = xmlhttp.responseText end if set xmlhttp = nothing