- Home /
does UnityWebRequest provide timeout ?
as far as I can tell from the documentation and testing, there is no mechanism for specifying a timeout for a UnityWebRequest, and that functionality needs to be provided by the developer in some sort of wrapper.
specifically, there's no mention of timeout in any UWR constructors, nor in any response/status codes.
the example code below returns after 10 seconds, because it's waiting for the server to respond.
i'm a fan of letting a request take as long as it wants, but i'd also prefer not to implement timeout myself.
private IEnumerator crSlowRequest() {
string url = "http://httpbin.org/delay/10";
Debug.Log("requesting " + url + "....");
UnityEngine.Networking.UnityWebRequest uwr = UnityEngine.Networking.UnityWebRequest.Get(url);
float t1 = Time.realtimeSinceStartup;
yield return uwr.Send();
float t2 = Time.realtimeSinceStartup;
Debug.Log("request seconds: " + (t2 - t1) + " isError: " + uwr.isError + " error: " + uwr.error + " responseCode: " + uwr.responseCode + " responseContent: " + uwr.downloadHandler.text);
}
Answer by LucktasticWill · Oct 13, 2017 at 05:53 PM
In case you're still looking for an answer, UnityWebRequest does have a timeout parameter.
well, Hot-Diggity !
thanks.
i'd implemented my own via a coroutine polling IsDone, but this is better.
Your answer
Follow this Question
Related Questions
why does UnityWebRequest want Dispose() ? 1 Answer
Server-Side Events with UnityHTTPWebRequests (text/event-stream) 0 Answers
Working behind a proxy on client site 0 Answers
UnityWebRequest timing out ? Send() finishes but isDone = false 1 Answer
[iOS] WWW class sometimes doesn't return a response 0 Answers