0 Replies Latest reply on Aug 28, 2014 8:35 AM by Gokhan137

    XMLSocket Not Connecting In-Browser Actionscript 2


      I'm currently running a PHP socket server. I'm also using a Flash client that uses the XMLSocket class to connect to that specific server as well.


      When I publish/preview the movie within Flash, everything works perfectly (it is able to establish a connection to the server). However, when I upload the SWF to my server (the same one that's running the socket server), and access the SWF file via my browser, the file fails to connect to the socket server!


      I've even tried to add a crossdomain.xml file to the root of my site, and have used `Security.loadPolicyFile()` to load it within the SWF, but that does not work as well.


      This is the actionscript for my SWF file:

          Security.loadPolicyFile("http://IP ADDRESS/crossdomain.xml");






          var theSocket:XMLSocket = new XMLSocket();

          theSocket.connect("IP ADDRESS", 9000);

          theSocket.onConnect = function(myStatus) {

              if (myStatus) {

                  conn_txt.text = "Connected!";

              } else {

                  conn_txt.text = "Failed to connect.";



      This is my crossdomain.xml file:


          <?xml version="1.0"?>
          <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
          <!-- Policy file for xmlsocket://socks.example.com -->
             <!-- This is a master-policy file -->
             <site-control permitted-cross-domain-policies="master-only"/>
             <!-- Instead of setting to-ports="*",
          administrators can use ranges and commas -->
             <!-- This will allow access to ports 123, 456, 457, and 458 -->
             <allow-access-from domain="*" to-ports="*" />


      `conn_txt`'s value is always "Failed to connect" from the browser, and "Connected" when I run it from Flash.


      This is the link structure for where I access the SWF from, if that would be of any help:

          http://IP ADDRESS/chat/chat.swf

      Any feedback would be HIGHLY appreciated, I have been working all day on this...