- Home /
Why is www not returning?
I have the following Code which I call from StartCoroutine
IEnumerator WaitForRequest(WWW www)
{
yield return www;
Debug.Log(www.text);
}
For the most part this works. The web request is being made ( I can debug it on my server) and everything works fine. But sometimes it doesn´t. In thouse cases I have the exact same web request an when I debug I can see that the www has the correct text (the web request has been made) but the Debug.Log is never reached.
Does anybody have any idea what could be the problem? Thanks in advance!
Answer by Johanna_H · Aug 07, 2017 at 08:45 AM
I solved this problem by waiting for the www return manually. So I don´t use StartCoroutine anymore. Instead I use a while loop and my programm works as expected! This is a workaround. I don´t really know what exactly went wrong but in case anybody else has this problem you can do this to solve it.
This is not recommended. This won't work in a WebGL builds. Using a coroutine is the prefered way. $$anonymous$$eep in $$anonymous$$d that when the object that hosts the coroutine is destroyed, deactivated or you call StopAllCoroutines on that object, your coroutine will be ter$$anonymous$$ated.
I've used basically exactly the same code you have in your question in various projects (WebGL, Android, standalone) and i never had any problems.
Answer by tranvanquyet · Aug 07, 2017 at 09:26 AM
string url ="abc" ; IEnumerator WaitForRequest() { WWW www = new WWW(url); yield return www; Debug.Log(www.text); }
That is exactly what I did and where I had my problem... But thanks for the reply.
Your answer
Follow this Question
Related Questions
Using async WebRequest GetResponse 1 Answer
Upload files to a remote form using C# in Unity 2 Answers
Unity 2018 hits don't show in Google Analytics 2 Answers
Download progress is -1 forever. 2 Answers
How to avoid reestablishing an HTTPS request, use Connection: Keep-Alive or reuse WWW object? 2 Answers