Trapping errors from System.Net.WebRequest

Posted by MBeynon on 23-Jan-2018 09:40


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
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

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?



All Replies

Posted by MBeynon on 23-Jan-2018 10:10

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!

This thread is closed