PDA

View Full Version : xmlsocket and policy-file-request



uberalles
June 20th, 2008, 12:32 PM
I have a chat server written in Java listening on port 6000 and a client app(using an xmlsocket) in Flash 9. I get these <policy-file-request/>. I understand the purpose and I read the one solution about creating a server on port 843 and serving a master policy file but since I do not have total control over our hosting I cannot use port 843.
I also tried replying to the request with "<cross-domain-policy><allow-access-from domain='*' to-ports='*'/></cross-domain-policy>" + "\0" but nothing happens.
The other really strange thing is that using Firefox the file request waits for the response and does nothing...but in IE7 the file request goes through then it continues to work even with no response, I can send/receive using the socket without problem.
Does anyone know a good way to 'satisfy' the file request using the Java server listening on port 6000?
Big thanks in advance.

samiy
June 26th, 2008, 06:10 PM
I have same problem. Do you find any solution?

Thanks

uberalles
June 26th, 2008, 09:51 PM
Wow....you're the only person I've seen so far with the same problem. I found that if I sent the following:
"<cross-domain-policy><allow-access-from domain='*' to-ports='*'/></cross-domain-policy>" + "\0" before doing any readLine on the socket it works...but if I try and read first Flash just seems to sit there waiting.
Hope this helps.

bazzil
July 6th, 2008, 12:32 PM
look at this link. it has an example for php but it is the same for other langs.
just send the $policy_file at the first time when a client connect.

http://board.flashkit.com/board/showthread.php?t=757231

sdpagent
February 27th, 2009, 12:10 PM
i tried your solutions, using the \0 to end the statement as a null byte and trying to send the policy file request as soon as someone connects. It still doesn't work for me

i used:

String policy = "<?xml version=\"1.0\"?><cross-domain-policy><allow-access-from domain=\"*\" to-ports=\"*\" /></cross-domain-policy>" + "\0";

connection.getBufferedWriter().write(policy);


is that not correct? Do you have to never read form the connection?



more details can be found here
http://sdpagent.wordpress.com/2009/02/27/flash-cross-domain-policy-and-the-policy-file-request/

uberalles
February 27th, 2009, 03:51 PM
I can't say for sure that this will work....but what I ended up doing is just sending the policy file (xml crap) whenever a new connection comes in. I don't check for anything first, all I do is send the xml chunk to a new connection as soon as it comes in. It worked for me but it does seem a little strange to have to do it that way.