Search Unity

[url]www.error[/url] always returns null on the server

Discussion in 'Editor & General Support' started by firas darwiche, Jan 10, 2010.

  1. firas darwiche

    firas darwiche

    Joined:
    Oct 4, 2006
    Posts:
    130
    when I Upload the unity file and html to the server, www.error always returns null.

    it works fine however if I open the html file on my disk without uploading it to the server.

    I'm using 2.5
     
  2. LukeB

    LukeB

    Joined:
    Aug 8, 2009
    Posts:
    88
    www.error returns if an error has actually happened (e.g theres no internet connectivity, so unity couldn't send the data, or the page doesn't exist). The best way to use www.error is something like this:
    Code (csharp):
    1.  
    2. mywww=WWW("http://....");
    3. yield mywww;
    4. if(mywww.error){
    5. print("Error: "+mywww.error);
    6. }else{
    7. print([url]www.data[/url]);
    8. }
    hope that helps!
     
  3. firas darwiche

    firas darwiche

    Joined:
    Oct 4, 2006
    Posts:
    130
    hello luke, thanks for replying.

    I'm doing just as u indicated and in ur code:

    mywww=WWW("http://....");
    yield mywww;
    if(mywww.error){
    print("Error: "+mywww.error);
    }else{
    print(www.data);
    }

    the statement "if(mywww.error)" always returns false when i build for web and host my files on the server (hosted by doteasy.com)

    it works fine, however, when I build for web and play it on my computer locally (returns true sometimes and false other times as expected).
     
  4. LukeB

    LukeB

    Joined:
    Aug 8, 2009
    Posts:
    88
    If your using an ip address (e.g http://123.123.123.123/) or localhost (http://localhost/ or http://127.0.0.1/) in the WWW then that is most likely the cause of the problem. Calling 'localhost' makes it look around the computer that is currently running the unity client and not on the net.

    If that's not the cause of the problem then have you:

    - tried using a different url instead that you are certain is always online? (like http://www.google.com/)

    or

    - checked your url has got http:// in it? (Minor but sometimes makes a huge difference!)

    Also it might make a difference if your using 'web player streamed' as the build method. I've always found that the ordinary web player is better to use :)