- Home /
Policy File is being served, but never recognized
I am trying to serve a crossdomain policy file from a Java server to the Unity webplayer. When the webplayer connects to the server, the console (server-side) shows: "ServingPolicyFile CONNECTION MADE", but the webplayer throws an exception:
SecurityException: Unable to connect, as no valid crossdomain policy was found
System.Net.Sockets.Socket.Connect_internal (IntPtr sock, System.Net.SocketAddress sa, System.Int32& error, Boolean requireSocketPolicyFile)
System.Net.Sockets.Socket.Connect_internal (IntPtr sock, System.Net.SocketAddress sa, System.Int32& error)
System.Net.Sockets.Socket.Connect (System.Net.IPAddress[] addresses, Int32 port)
System.Net.Sockets.Socket.Connect (System.String host, Int32 port)
Here is the server code (Java)
public class ServingPolicyFile {
final private static int PORT = 843;
final private static String POLICY_FILE_FORMAT = "<?xml version='1.0'?><cross-domain-policy><allow-access-from domain=\"%s\" to-ports=\"%s\"/></cross-domain-policy>\0";
final private ExecutorService _executor = Executors.newSingleThreadExecutor();
final private ServerSocket _servingSocket;
final private String _policyFile;
public ServingPolicyFile(String policyFile) throws IOException {
_servingSocket = new ServerSocket(PORT);
_policyFile = policyFile;
}
public ServingPolicyFile(int port) throws IOException {
this(String.format(POLICY_FILE_FORMAT, "*", port));
}
public void close() throws IOException {
_executor.shutdownNow();
_servingSocket.close();
}
public void start() {
_executor.submit(() -> {
while (true) {
try (Socket socket = _servingSocket.accept(); PrintWriter out = new PrintWriter(socket.getOutputStream(), true)) {
System.out.println("ServingPolicyFile CONNECTION MADE");
out.println(_policyFile);
}
}
});
}
}
Does anyone know what the issue might be?
I tried serving the EXACT policy file (copy & pasted) from the unity docs, but that didn't work either.
Answer by Hoten · Feb 15, 2015 at 10:04 PM
I was able to fix my issue. I was sending the policy file correctly, but my application was crashing. I misdiagnosed this as the policy file failing.
I found this information by checking the Editor log file. You can find this on your machine by reading this:
http://answers.unity3d.com/questions/9739/how-can-i-find-editor-log-file.html
Your answer
Follow this Question
Related Questions
Web Player connection issue. 0 Answers
Security.PrefetchSocketPolicy problem. 0 Answers
CrossDomain.xml issue 1 Answer
How to prevent a Webplayer Game from being saved locally? 1 Answer
Uniweb(sockets) + Facebook 0 Answers