Unity crossdomain.xml

I am getting error messages regarding the crossdomain.xml file and I am not sure how to solve it. I have no problem accessing the URL from a web browser.

From a web browser

http://192.168.1.116:80/locJSON.txt

      

returns me a large piece of JSON nicely

From a web browser

http://192.168.1.116/crossdomain.xml

      

returns me cross-domain 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 problems.

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 go past the while line, if I check inside the AIServer variable in the debugger, I see the message "System.Security.SecurityException: No valid cross-domain access policy to allow access" highlighted in red for AIServer.bytes, AIServer. data and AIServer.text

Also, I am getting the following messages in the console. Any insight would be appreciated.

UriFormatException: Invalid URI: Unable to determine the format of the URI.

MonoForks.System.Uri..ctor (System.String uriString, Boolean dontEscape) MonoForks.System.Uri..ctor (System.String uriString) (validated remote call-call-wrap) MonoForks.System.Uri: .ctor (string) MonoForks.System.Windows.Interop.PluginHost.get_SourceUri () MonoForks.System.Windows.Browser.Net.CrossDomainPolicyManager.GetCachedWebPolicy (MonoForks.System.Uri uri) UnityEngine. UnityEngine.UnityCrossDomainHelper.GetSecurityPolicy (System.String requesturi_string) UnityEngine.WWW: get_isDone () PlayEditorMain: QuerryAIServer () (in assets / scripts / scripts play editor / scripts menu / scripts menu / menu button / PlayEain button) playbacks / Menu Scripts / PlayEditorMain.cs: 262) MainMenuButton: OnClick () (in Assets / Scripts / Play Editor Scripts / Menu Buttons / MainMenuButton.cs: 23) UnityEngine.GameObject: SendMessage (String, Object, SendMessageOptions) UICa mera: Notify (GameObject, String, Object) (in assets / third-party developers / NGUI / scripts / UI / UICamera.cs: 765) UICamera: ProcessTouch ( logical, logical) (in assets / third-party development /NGUI/Scripts/UI/UICamera.cs: 1435) UICamera: ProcessMouse () (in Assets / Third-party vendors / NGUI / Scripts /UI/UICamera.cs: 1063) UICamera: Update () (under Assets / Third Party Components / NGUI / Scripts / User Interface / UICamera. CS: 909)1435) UICamera: ProcessMouse () (under Assets / Third Party Providers / NGUI / Scripts /UI/UICamera.cs: 1063) UICamera: Update () (under Assets / Third Party Components / NGUI / Scripts / User Interface / UICamera. Cs : 909)1435) UICamera: ProcessMouse () (under Assets / Third Party Providers / NGUI / Scripts /UI/UICamera.cs: 1063) UICamera: Update () (under Assets / Third Party Components / NGUI / Scripts / User Interface / 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)

      

+3


source to share


2 answers


One thing that got me over a couple of times is not saving it as UTF-8 encoding. Some editors do this if you open it in notepad and save it after making changes. Notepad (at least version in Windows 8.1) has a select box to check the type of encoding 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 clarity, the tags in the crossdomain should be surrounded <cross-domain-policy></cross-domain-policy>

and the very first element, as with all XML files <?xml version="1.0" ?>

in general ..



<?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>

      

+1


source


Try this standard to 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>

      

0


source







All Articles