Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

WWW is not giving any Response in WEBGL Build

Discussion in 'WebGL' started by RJproz, Apr 22, 2015.

  1. RJproz

    RJproz

    Joined:
    May 19, 2013
    Posts:
    52
    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.



    Code (CSharp):
    1. IEnumerator TestWWW()
    2. {
    3.         log = "Waiting..";
    4.         yield return new WaitForSeconds (2);
    5.         log = "Requesting";
    6.  
    7.  
    8.         WWW www = new WWW ("http://hybriona.com",null,headers);
    9.         yield return www;
    10.          log = "Response";
    11.         if(www.error == null)
    12.         {
    13.             log = www.text;
    14.         }
    15.         else
    16.         {
    17.             log = www.error;
    18.         }
    19.  
    20.  
    21.        
    22.                
    23. }
    And it seems that it never goes past of " yield return www;"


    Is there anything i m missing?
     
  2. RJproz

    RJproz

    Joined:
    May 19, 2013
    Posts:
    52
  3. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    5.1 should fix WWW class error reporting in WebGL
     
    liortal likes this.
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    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: https://gist.github.com/liortal53/ff9e1b7d0d5ddc5e37dd

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

    Code (CSharp):
    1. WWW www = new WWW ("http://hybriona.com",null,headers);
    2. yield return www;
    You would write this code:

    Code (CSharp):
    1. WWW www = new WWW ("http://hybriona.com",null,headers);
    2. yield return StartCoroutine(new WWWRequest(www));
    Let me know if that works out for you, or if you have any questions.

    Thanks
    Lior
     
  5. instruct9r

    instruct9r

    Joined:
    Aug 1, 2012
    Posts:
    148
    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...
     
    olegfix likes this.
  6. instruct9r

    instruct9r

    Joined:
    Aug 1, 2012
    Posts:
    148
    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?
     
    olegfix likes this.