- Home /
WWW Error in Web Player
I've got some problem with Unity3d WWW class.
I'm trying to get string from an URL, it works fine in unity editor, but when I build into Web Player, it does not working. its like the coroutine always trying to get data (I'm not set the time out), but got nothing, "WWW.error" properties is also null, if I use "while(www.isDone){}" it will be blocking (never enter into the scene/level). Can anyone help?
here are the coroutine code:
public IEnumerator SubmitLogin()
{
WWW download = new WWW("http://targetdomain/index.php?op=login&username=user&password=pwd");
yield return download;
// this is will be blocking forever in web player
//while(!download.isDone){}
if(download == null)
{
Debug.Log("download data is null");
}
else
{
//_sessionId = download.text;
Debug.Log(download.text);
}
if(download.error != null)
{
Debug.Log("Download error" + download.error);
_sessionId = "SESSION EMPTY, " + download.error;
}
}
PS: Now I get the error message, the error message was "rejected because no crossdomain.xml policy file was found". It was weird, since I already have that file in a correct place.
Answer by zwacky · Jun 15, 2011 at 09:15 AM
methods of return type IEnumerator
shouldn't return any values as you did with
yield return download;
the usual snippet would be
yield download; // only proceed if download is complete
also make sure that your crossdomain.xml is accessible like http://targetdomain/crossdomain.xml with the right entries like this template (whereas everything is allowed)
<cross-domain-policy>
<allow-access-from domain="*"/>
<site-control permitted-cross-domain-policies="master-only"/>
</cross-domain-policy>
Thanks Zwacky.
Yes you were correct I must use "yield download;" if I'm using javascript, but my code above is using C#.
I have already put crossdomain.xml in correct place, in this case htdocs folder of XA$$anonymous$$PP. but still the result is "error because no crossdomain.xml policy file found". Is this a bug?
omg my bad, brainlagging at the c#. i assume, that both - your webplayer and your page - is not in a private network but reachable for everyone?
this error would imply that it is reachable for your game, but since it's on a different domain, you have to access his crossdomain.xml which seems not to be present on that host (most possibly you already knew this, but just for the record). the error is related to your web configuration, not to unity.
i once used WWW classes along with crossdomain.xml and i didn't have any trouble.