Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
Thread: Allowing XMLSocket Connections
01-12-2009, 11:02 PM #1
Allowing XMLSocket Connections
I'm writing a chat client in Flash 8 that uses XMLSockets to connect to a server. Is there a way to set up the client and/or server with policy files, HTML param tags, etc to allow the socket connection without the user having to allow it using the Flash Player Settings Manager?
01-13-2009, 08:32 AM #2
- Join Date
- Sep 2007
- Thanked 238 Times in 229 Posts
I have never used this feature, but I would think having a crossdomain.xml policy file (with all sites permitted) is the first step to try.
01-13-2009, 06:10 PM #3
I've tried that, and I've tried manually loading the policy file with System.security.loadPolicyFile (not sure if this is needed, but I tried anyway).
I can connect to a server and send and receive data from the built-in player in Adobe Flash. When I run the swf movie locally in a standalone player, I get a security warning saying that the player has stopped a potentially unsafe operation, and the connection doesn't even return a failure (no onConnect event). But when I run it in a browser from a webserver, it at least attempts a connection (and the onConnect handler is called with a false success parameter).
EDIT: Demo Flash movie and source code available here if it helps. I have the server running, but this movie (on the same machine and IP as the server) can't connect to it.
Last edited by thesmart1; 01-13-2009 at 07:19 PM.
01-14-2009, 12:42 AM #4
Oh wow, after some packet-watching with Wireshark, communication monitoring with telnet and server-side packet logging, and lots of research, I noticed Flash Player was indeed connecting to first port 843, then port 80 (when i used loadPolicyFile with a port number), then the port of my server program. I still can't figure out why the HTTP request to port 80 failed though; I found a single request in the Apache access logs:
"GET /crossdomain.xml HTTP/1.1" 200 543 "http://pehjota.com/crossdomain.xml" "Shockwave Flash". On my server I noticed Flash was sending
<policy-file-request/>, so I passed the contents of my crossdomain.xml file through the socket and Flash Player accepted it. So after several hours of investigation I finally got my Flash Player client to connect to and communicate with my server! Though it's still a bit weird that Flash Player only sent one HTTP request and seemed it didn't like the response, and so now I have to add a response to my server to handle policy file requests...
More information on policy files and how they relate to socket connections - specifically of interest on that page is "Socket policy request process"