3

I'm getting error messages regarding the crossdomain.xml file and I don't know how to resolve it. I have no trouble accessing the URL from a web browser.

From web browser

http://192.168.1.116:80/locJSON.txt

gives me back a big snippet of JSON nicely

From web browser

http://192.168.1.116/crossdomain.xml

gives me back the crossdomain information

<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" to-ports="*" secure="false"/>
<allow-access-from domain="*" to-ports="*"/>
<allow-access-from domain="*"/>
<allow-http-request-headers-from domain="*"  to-ports="*"/>
<allow-http-request-headers-from domain="*"/>
<site-control permitted-cross-domain-policies="all"/>

But from within Unity, if I try the following code I get issues.

private void QueryAIServer()
{
    string url = "http://192.168.1.116/locJSON.txt";
    WWW AIServer = new WWW(url);

    while(!AIServer.isDone) { };

    Debug.Log("Connected to AI Server!");
}

When I get past the while line, if I inspect inside the AIServer variable in the debugger, I can see the message "System.Security.SecurityException: No valid crossdomain policy available to allow access" drawn in red for AIServer.bytes, AIServer.data, and AIServer.text

Also, I do get the following messages output in the console. Any insight would be appreciated.

UriFormatException: Invalid URI: The format of the URI could not be determined.

MonoForks.System.Uri..ctor (System.String uriString, Boolean dontEscape) MonoForks.System.Uri..ctor (System.String uriString) (wrapper remoting-invoke-with-check) MonoForks.System.Uri:.ctor (string) MonoForks.System.Windows.Interop.PluginHost.get_SourceUri () MonoForks.System.Windows.Browser.Net.CrossDomainPolicyManager.GetCachedWebPolicy (MonoForks.System.Uri uri) UnityEngine.UnityCrossDomainHelper.GetSecurityPolicy (System.String requesturi_string, IPolicyProvider policyProvider) UnityEngine.UnityCrossDomainHelper.GetSecurityPolicy (System.String requesturi_string) UnityEngine.WWW:get_isDone() PlayEditorMain:QuerryAIServer() (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:556) PlayEditorMain:ButtonPressed(GameObject) (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:262) MainMenuButton:OnClick() (at Assets/Scripts/Play Editor Scripts/Menu Buttons/MainMenuButton.cs:23) UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions) UICamera:Notify(GameObject, String, Object) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:765) UICamera:ProcessTouch(Boolean, Boolean) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1435) UICamera:ProcessMouse() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1063) UICamera:Update() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:909)

You are trying to load data from a www stream which had the following error when downloading. Rejected because no crossdomain.xml policy file was found UnityEngine.WWW:get_assetBundle() PlayEditorMain:QuerryAIServer() (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:559) PlayEditorMain:ButtonPressed(GameObject) (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:262) MainMenuButton:OnClick() (at Assets/Scripts/Play Editor Scripts/Menu Buttons/MainMenuButton.cs:23) UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions) UICamera:Notify(GameObject, String, Object) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:765) UICamera:ProcessTouch(Boolean, Boolean) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1435) UICamera:ProcessMouse() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1063) UICamera:Update() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:909)

Unable to determine the audio type from the URL (http://192.168.1.116/locJSON.txt) . Please specify the type. UnityEngine.WWW:get_audioClip() PlayEditorMain:QuerryAIServer() (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:559) PlayEditorMain:ButtonPressed(GameObject) (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:262) MainMenuButton:OnClick() (at Assets/Scripts/Play Editor Scripts/Menu Buttons/MainMenuButton.cs:23) UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions) UICamera:Notify(GameObject, String, Object) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:765) UICamera:ProcessTouch(Boolean, Boolean) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1435) UICamera:ProcessMouse() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1063) UICamera:Update() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:909)

Streaming of 'ogg' on this platform is not supported UnityEngine.WWW:get_oggVorbis() PlayEditorMain:QuerryAIServer() (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:559) PlayEditorMain:ButtonPressed(GameObject) (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:262) MainMenuButton:OnClick() (at Assets/Scripts/Play Editor Scripts/Menu Buttons/MainMenuButton.cs:23) UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions) UICamera:Notify(GameObject, String, Object) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:765) UICamera:ProcessTouch(Boolean, Boolean) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1435) UICamera:ProcessMouse() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1063) UICamera:Update() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:909)

You are trying to load data from a www stream which had the following error when downloading. Rejected because no crossdomain.xml policy file was found UnityEngine.WWW:get_size() PlayEditorMain:QuerryAIServer() (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:559) PlayEditorMain:ButtonPressed(GameObject) (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:262) MainMenuButton:OnClick() (at Assets/Scripts/Play Editor Scripts/Menu Buttons/MainMenuButton.cs:23) UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions) UICamera:Notify(GameObject, String, Object) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:765) UICamera:ProcessTouch(Boolean, Boolean) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1435) UICamera:ProcessMouse() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1063) UICamera:Update() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:909)

You are trying to load data from a www stream which had the following error when downloading. Rejected because no crossdomain.xml policy file was found UnityEngine.WWW:get_texture() PlayEditorMain:QuerryAIServer() (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:559) PlayEditorMain:ButtonPressed(GameObject) (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:262) MainMenuButton:OnClick() (at Assets/Scripts/Play Editor Scripts/Menu Buttons/MainMenuButton.cs:23) UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions) UICamera:Notify(GameObject, String, Object) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:765) UICamera:ProcessTouch(Boolean, Boolean) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1435) UICamera:ProcessMouse() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1063) UICamera:Update() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:909)

You are trying to load data from a www stream which had the following error when downloading. Rejected because no crossdomain.xml policy file was found UnityEngine.WWW:get_textureNonReadable() PlayEditorMain:QuerryAIServer() (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:559) PlayEditorMain:ButtonPressed(GameObject) (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:262) MainMenuButton:OnClick() (at Assets/Scripts/Play Editor Scripts/Menu Buttons/MainMenuButton.cs:23) UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions) UICamera:Notify(GameObject, String, Object) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:765) UICamera:ProcessTouch(Boolean, Boolean) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1435) UICamera:ProcessMouse() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1063) UICamera:Update() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:909)

Unable to determine the audio type from the URL (http://192.168.1.116/locJSON.txt) . Please specify the type. UnityEngine.WWW:get_audioClip() PlayEditorMain:QuerryAIServer() (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:559) PlayEditorMain:ButtonPressed(GameObject) (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:262) MainMenuButton:OnClick() (at Assets/Scripts/Play Editor Scripts/Menu Buttons/MainMenuButton.cs:23) UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions) UICamera:Notify(GameObject, String, Object) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:765) UICamera:ProcessTouch(Boolean, Boolean) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1435) UICamera:ProcessMouse() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1063) UICamera:Update() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:909)

Connected to AI Server! UnityEngine.Debug:Log(Object) PlayEditorMain:QuerryAIServer() (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:558) PlayEditorMain:ButtonPressed(GameObject) (at Assets/Scripts/Play Editor Scripts/Menu Scripts/PlayEditorMain.cs:262) MainMenuButton:OnClick() (at Assets/Scripts/Play Editor Scripts/Menu Buttons/MainMenuButton.cs:23) UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions) UICamera:Notify(GameObject, String, Object) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:765) UICamera:ProcessTouch(Boolean, Boolean) (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1435) UICamera:ProcessMouse() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:1063) UICamera:Update() (at Assets/3rd Party/NGUI/Scripts/UI/UICamera.cs:909)
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Dalanchoo
  • 177
  • 1
  • 3
  • 17

2 Answers2

1

One thing that has gotten me on this multiple times is not saving it as UTF-8 encoded. Some editors do this if you've opened it in say notepad and re-saved it after making changes. Notepad (at least the version in Windows 8.1) has a select box for checking the encoding type you want to use when saving and it defaults to ANSI.

Edit: One thing I want to make sure - and I'm sure you just omitted it, but just for the sake of clarity, the tags in the crossdomain need to be surrounded by <cross-domain-policy></cross-domain-policy> and the very first element as with all XML files needs to be <?xml version="1.0" ?> In total..

<?xml version="1.0" ?>
<cross-domain-policy>
    <site-control permitted-cross-domain-policies="all"/>
    <allow-access-from domain="*" to-ports="*" secure="false"/>
    <allow-access-from domain="*" to-ports="*"/>
    <allow-access-from domain="*"/>
    <allow-http-request-headers-from domain="*"  to-ports="*"/>
    <allow-http-request-headers-from domain="*"/>
    <site-control permitted-cross-domain-policies="all"/>
</cross-domain-policy>
aqez
  • 182
  • 1
  • 9
0

Try this standard allow all crossdomain.xml:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>

   <allow-access-from domain="*" secure="false" />
</cross-domain-policy>
Cameron
  • 1,524
  • 11
  • 21