T
T
TheTalion2017-07-17 23:31:02
Unity
TheTalion, 2017-07-17 23:31:02

What is the reason for the incomprehensible coroutine delay in UnityWebRequest?

There is a server and a client, now on the same machine, but the problem is that there is a delay of 3 seconds, which, apparently, occurs in the waiting coroutine, but why it occurs is not clear.
The coroutine itself looks something like this:

IEnumerator GetText() {
        UnityWebRequest www = new UnityWebRequest("http://www.my-server.com");
        www.downloadHandler = new DownloadHandlerBuffer();
        yield return www.Send();
 
        if(www.isError) {
            Debug.Log(www.error);
        }
        else {
            // Show results as text
            Debug.Log(www.downloadHandler.text);
 
            // Or retrieve results as binary data
            byte[] results = www.downloadHandler.data;
        }
    }

The timing check is as follows:
Command sendind 7/17/2017 9:54:19 PM
Prestarting Courotine 7/17/2017 9:54:19 PM
Startind curutine 7/17/2017 9:54:19 PM
OnHttpRequest 7/17/2017 9 :54:22 PM
Get response 7/17/2017 9:54:22 PM
Remove connections 7/17/2017 9:54:22 PM
Command sendind 7/17/2017 9:54:22 PM
Prestarting Courotine 7/17/ 2017 9:54:22 PM
Startind courutine 7/17/2017 9:54:22 PM
OnHttpRequest 7/17/2017 9:54:25 PM
Get response 7/17/2017 9:54:25 PM
You can see that the delay in 3 seconds. How and why is not clear to me. What could be the reasons based on the data I provided?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question