From d6e50beaae25944a3762ed3de5dd95aa9472d32d Mon Sep 17 00:00:00 2001 From: giudig <47992054+giudig@users.noreply.github.com> Date: Wed, 15 Dec 2021 17:07:30 +0100 Subject: [PATCH] Handle http.send possible connection issues Handle http.send error "A connection with the server could not be established" --- check_http_win.vbs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/check_http_win.vbs b/check_http_win.vbs index 6b89922..8b230c2 100644 --- a/check_http_win.vbs +++ b/check_http_win.vbs @@ -61,12 +61,21 @@ End If ' Run the magic Set http = CreateObject("MSXML2.ServerXMLHTTP") http.open MyMethod,MyUrl,false + +' Handle http.send possible connection issues +On Error Resume Next If (MyMethod = "POST") Then http.send MyData Else http.send End If +If Left(Err.Description,53) = "A connection with the server could not be established" Then + wScript.Echo "Error in http.send: " & Err.Description + exitCode = 2 + WScript.Quit(exitCode) +End If + ' Handle return status ' No expected status given, use default handling of http status codes If MyExpectIgnore = 1 Then