Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder thesmart1's Avatar
    Join Date
    Dec 2005
    Posts
    369
    Thanks
    7
    Thanked 3 Times in 3 Posts

    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?

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    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.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #3
    Regular Coder thesmart1's Avatar
    Join Date
    Dec 2005
    Posts
    369
    Thanks
    7
    Thanked 3 Times in 3 Posts
    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.

  • #4
    Regular Coder thesmart1's Avatar
    Join Date
    Dec 2005
    Posts
    369
    Thanks
    7
    Thanked 3 Times in 3 Posts
    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"


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •