문제

저는 이전 ASP/VBScript 사이트의 다른 서버에서 일부 정보를 가져오기 위해 Microsoft.XMLHTTP를 사용하고 있습니다.하지만 다른 서버는 상당히 자주 다시 시작되므로 정보를 가져오기 전에 해당 서버가 제대로 작동하고 있는지 확인하고 싶습니다(또는 다른 방법으로 문제를 감지하여 내 페이지에서 HTTP 500을 제공하지 않도록 방지).

ASP로 이 작업을 어떻게 수행할 수 있습니까?

도움이 되었습니까?

해결책

당신이 해야 할 일은 오류가 발생한 경우에도 코드를 계속 실행하도록 한 다음, 다른 서버에 게시하고 게시물에서 상태를 읽는 것뿐입니다.이 같은:

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

다른 팁

서버에 ping을 시도하고 응답을 확인할 수 있습니다.이것을보세요 기사.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top