x


Rejected because no crossdomain.xml policy file was found

I am using Apache server to host my Unity game. I also have a php file on the server to write game data to a database.

I have a crossdomain.xml file at the root of the server which contains the following:

<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>

I am also running 'sockpol --all' on the server.

When I call 'ret = Security.PrefetchSocketPolicy("server ip", 843);' it returns false and when the hs_post = WWW(gamedata_url) call is made it returns the error 'Rejected because no crossdomain.xml policy file was found'.

I know the code is correct because when I run it using a local server it writes to the database correctly. It is only when I place the php file on the server and try to access it remotely that it doesn't work. I have spent many hours trying to resolve this issue without any success. Any help would be greatly appreciated.

more ▼

asked Jul 19 '11 at 03:35 PM

user-12176 (google) gravatar image

user-12176 (google)
11 2 2 4

My crossdomain file never got read properly until I opened it and saved it with a text editor (vi) on the server.

It wasn't working at first and I found a thread here about people having issues due to the character set used by their text editors. I opened with vi, saved, exited, and it worked.

Small chance it works for you, but thought I'd mention it....

Jul 19 '11 at 04:36 PM jahroy
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

There are a few comments to make.

  1. Firstly, the sockpol application is there to support clients that need to make access to your server using sockets. If you are only using the WWW class then you should not need this application running, and the Unity webplayer will not connect to your server over port 843.
  2. The Security.PrefetchSocketPolicy is not needed if you are using the WWW class (only).
  3. The first time you make a WWW request to a URL different from where the unity3d file comes from Unity will try to read the crossdomain.xml file from your server. You may care to examine your server logs to determine if this file has been requested and returned. It's possible your server is not configured to serve XML files. (You could also try to fetch the crossdomain.xml directly using a web browser and checking that the server delivers it. Or try using curl to fetch it.)
  4. As jahroy says, the crossdomain.xml must be a pure ascii file, as per the documentation.
more ▼

answered Jul 19 '11 at 06:52 PM

Graham Dunnett gravatar image

Graham Dunnett ♦♦
18.5k 12 23 82

(comments are locked)
10|3000 characters needed characters left

Thanks for the swift replies. I have already tried that Jahroy, both UTF-8 and ASCII but no luck. Your advice should be helpful in narrowing down the problem Graham, no that I know sockpol and Security.PrefetchSocketPolicy are not relevant for what I'm trying to achieve. I have previously tried fetching the xml file directly through the browser and that works no problem. I will look through the log files to see if that will shed any light on the problem. I will need to look into whether or not Apache can serve xml files. Perhaps you can suggest a Windows server which will definitely serve the xml file and therefore work with Unity webplayer out of the box? Thanks again guys, your feedback is much appreciated...,Thanks Jahroy and Graham, I appreciate your swift replies. I have tried encoding the xml file in both UTF-8 and ANSI and neither made any difference unfortunately. It is good to know that 'Security.PrefetchSocketPolicy' is not need for what I'm trying to achieve Graham, could help me narrow down the problem. I have also tried checking if it is delivered directly and it is...I will need to look into configuring Apache to serve XML files. Perhaps you could suggest another Windows server which will definitely work in this way?... Thanks again guys...

more ▼

answered Jul 19 '11 at 07:34 PM

user-12176 (google) gravatar image

user-12176 (google)
11 2 2 4

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x725
x345
x5
x3

asked: Jul 19 '11 at 03:35 PM

Seen: 9435 times

Last Updated: Nov 05 '13 at 12:25 PM