Search Unity

WWW not working at all from web player?

Discussion in 'Editor & General Support' started by ceteris, Mar 2, 2008.

  1. ceteris

    ceteris

    Joined:
    Feb 9, 2008
    Posts:
    25
    I cant get WWW to work from the webplayer...

    it works from the editor, from a standalone for mac, but not from any browser I've tested. I must be doing something stupid...

    are there security settings in the browser to worry about? I am behind a router, which is probably using some version of NAT, but from the same machine, the standalone works, the web player doesnt.

    here is a simple test app I created. am I doing something wrong there?

    thanks!

    Code (csharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using System.Collections;
    5.  
    6. public class NetTest : MonoBehaviour
    7. {
    8.  
    9.     public string message = "ready to run test";
    10.     private Rect centerRect = new Rect(Screen.width / 4, Screen.height / 4, Screen.width / 2, Screen.height / 2);
    11.  
    12.  
    13.     void OnGUI()
    14.     {
    15.         GUILayout.BeginArea(centerRect);
    16.         GUILayout.TextArea(message);
    17.         if (GUILayout.Button("run test"))
    18.         {
    19.             StartCoroutine("ping");
    20.         }
    21.         if (GUILayout.Button("kill coroutine"))
    22.         {
    23.             StopCoroutine("ping");
    24.         }
    25.         GUILayout.EndArea();
    26.  
    27.     }
    28.  
    29.  
    30.     IEnumerator ping()
    31.     {
    32.  
    33.         string pingURL = "www.google.com";
    34.         WWW httpCall = new WWW(pingURL);
    35.        
    36.  
    37.         while (!httpCall.isDone)
    38.         {
    39.             message = "waiting for ping";
    40.             yield return new WaitForSeconds(1);
    41.         }
    42.         if (httpCall.error != null)
    43.         {
    44.             message = "failed! error message= " + httpCall.error;
    45.         }
    46.         else
    47.         {
    48.             string response = httpCall.data;
    49.             if (response.Length > 0)//assume for now that getting back anything counts as success...
    50.             {
    51.                 message = "ping succeeded";
    52.             }
    53.         }
    54.  
    55.     }
    56.  
    57. }
     
  2. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    Have you tried applying http:// in front of the address? If that works, you should bug report that there is an inconsistency between players, due to the fact that in the web player the requests are going through the browser instead of libcurl.

    Cheers,
    -Jon
     
  3. ceteris

    ceteris

    Joined:
    Feb 9, 2008
    Posts:
    25
    phew... that was it. so, you'd call this a bug?
     
  4. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    Yeah, anything like that that happens differently in the Editor than in the web player is worth reporting. They love knowing about that kind of thing.

    Cheers,
    -Jon
     
  5. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104
    Yes we do!

    ... silly glitches may not be critical to fix, but the fact that we always try to fix them adds to the polish of this little baby of ours, Unity :)

    d.