A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: XMLSocket Not Connecting In-Browser Actionscript 2

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    2

    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:

    Code:
        Security.loadPolicyFile("http://IP ADDRESS/crossdomain.xml");
        
        /*
        SOCKET CONNECTION
        */
        
        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:

    Code:
        <?xml version="1.0"?>
        <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
        <!-- Policy file for xmlsocket://socks.example.com -->
        <cross-domain-policy>
           <!-- 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="*" />
        </cross-domain-policy>
    `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:

    Code:
        http://IP ADDRESS/chat/chat.swf
    Any feedback would be HIGHLY appreciated, I have been working all day on this...

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    are you using the correct ip address, as I think the address needs to be your actual ip address when connecting to it

    obviously the site ip address needs to be the site address

    my two cents

  3. #3
    Junior Member
    Join Date
    Aug 2014
    Posts
    2
    The address is the actual IP address, I was just using "IP ADDRESS" as a placeholder for the actual IP address in this post.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center