View Full Version : Allowing XMLSocket Connections
01-13-2009, 12:02 AM
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, 09:32 AM
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, 07:10 PM
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 (http://www.pehjota.com/connection.html) 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.
01-14-2009, 01:42 AM
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 (http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html) - specifically of interest on that page is "Socket policy request process"
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.