UnityWebRequest webRequest = UnityWebRequest.Post("www.webpage.com", form);
webRequest.timeout = 3;
yield return webRequest.SendWebRequest();
if (webRequest.isNetworkError || webRequest.isHttpError)
{
Debug.Log("Error: time out");
}
var s = webRequest.downloadHandler.text;
This script throws an exception Curl error 28: Connection timed out after 2000 milliseconds.
I tried to put webRequest.,isNetwotkError into the try catch block but it does not work the application crashed. What do you advice ? How can I handle the network errors ?
Same here. I am spawning a bunch of requests that I know will likely fail. I’d like them to fail quietly without spamming the console. Has anyone found a solution? Thanks!
Hello @ctykaya . I was having your same problem. It is unacceptable to show errors in console, so to fix it, I think the solution is not so optimal. There it goes:
webRequest.SendWebRequest();
n = 3;
while (n > 0)
{
if (n == 0) //3f is webRequest.timeout
{
webRequest.Abort();
break;
}
if (webRequest.isDone) break;
n--;
yield return new WaitForSeconds(1f); //adjust the interval of verify
}