WWW is not giving any Response in WEBGL Build

I m facing a weird issue in Unity 5.0.0 f4. I m using WWW to fetch Data from my Website. But it is not giving me any response. Not even an error or Exception. So i created a simple function to test it.

IEnumerator TestWWW()
{
        log = "Waiting..";
        yield return new WaitForSeconds (2);
        log = "Requesting";


        WWW www = new WWW ("http://hybriona.com",null,headers);
        yield return www;
         log = "Response";
        if(www.error == null)
        {
            log = www.text;
        }
        else
        {
            log = www.error;
        }


       
               
}

And it seems that it never goes past of " yield return www;"

Is there anything i m missing?

I got it solved from

I just needed to setup CORS.
Though it’s weird it didn’t give any error or exception. :smile:

5.1 should fix WWW class error reporting in WebGL

1 Like

Indeed, I believe I am the one who reported this bug.

If you can’t wait till 5.1, we used a workaround for our game to solve this issue, get it here: WWWRequest.cs · GitHub

It’s a wrapper around Unity’s WWW class, so instead of using it like this:

WWW www = new WWW ("http://hybriona.com",null,headers);
yield return www;

You would write this code:

WWW www = new WWW ("http://hybriona.com",null,headers);
yield return StartCoroutine(new WWWRequest(www));

Let me know if that works out for you, or if you have any questions.

Thanks
Lior

Hello.

I was wondering. Do i have to SetUp: CORS, if the WebGL is on the same FTP as the data, that it needs to get with the WWW class?

Because the docs says:
Basically any WWW request to a server which is different from the server hosting the WebGL content needs to be authorized by the server you are trying to access

My WebGL is on the same server, but i still don’t get anything from the www.text.

And the www.error just gives back Unknown Error.

Everything is working just fine if i am on WebPlayer, without crossdomain.xml

thanks…

1 Like

Dooesn’t matter… My problem was that i missed to type “www” on the address.

By the way i don’t understand a lot from web stuff, but why is this a problem.

For example if i try to load information from www.mydomain.com/somefile.php

Then i upload the Web Build (or WebGL) to www.mydomain.com/webBuild/

Now if i open the WebBuild as “mydomain.com/webBuild/index.html” - all of the WWW class doesn’t return anything.

But if i open it with: “www.mydomain.com/webBuild/index.html” everything works well. So why woud the missing of "www’ in the address make so much troubles?

1 Like