Trapping errors from System.Net.WebRequest - Forum - Community Groups - Progress Community

Trapping errors from System.Net.WebRequest

 Forum

Trapping errors from System.Net.WebRequest

  • Hi,

    I'm trying to connect to a URL in OE10.2B using System.Net.WebRequest;

    WebRequest = System.Net.HttpWebRequest:Create(CONNECTION_URL) NO-ERROR.

    I'd like to be able to trap any errors created by the server not being available but I get a system error;


    System.Net.WebException: Unable to connect to the remote server
    and
    System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:3000

    I've tried no-error and CATCH but so far without success. Ideally I'd like to be able to trap this error and then retry a number of times after a short pause. Is this possible?

    Thanks,

    Mark.

  • Update: I've had more success with ;

         webClient = NEW WebClient().

         webClient:Headers:Add("Content-Type", "application/x-www-form-urlencoded").

         lvcResult = webClient:DownloadString(CONNECTION_URL) NO-ERROR.

    I can suppress the error and test lvcResult!