XMLSocket Flash Client Does Not Connect to Server

I have a Flash client with which I want to connect to the server. Both use localhost and port 50,000, so there should be no problems between domains. I also set up the access network only in the publish settings. When I call the XMLSocket connection, the server seems to get a new connection. But the XMLSocket.onConnect callback does not succeed = true.

Any ideas on what might be wrong?

Here's the ActionScript to create the socket.

function myOnConnect(success) { if (success) { trace ("Connection succeeded!") inputText.text = "open"; // socket.send("1\n"); gotoAndPlay(2); } else { trace ("Connection failed!") inputText.text = "failed"; } } btnConnect.onRelease = function() { inputText.text = "started"; result = socket.connect("localhost", 50000); } socket = new XMLSocket(); socket.onConnect = myOnConnect; 
+2
actionscript flash sockets network-programming
source share
1 answer

This turned out to be a security issue. Flash Player has added security when using XMLSocket. Flash Player now looks for a policy file on port 843. An alternative is to view the swf of the policy file by calling Security.loadPolicyFile() . If the file exists and all security settings allow XMLSocket, a connection is created.

Check out the Adobe article on policy files and more details here . This is another good article about policy files .

Here is the policy file that finally worked for me. This is not restrictive. But, I thought that everything works for me, and then I do them correctly.

 <?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 socket policy file --> <!-- No other socket policies on the host will be permitted --> <!-- <site-control permitted-cross-domain-policies="all"/> --> <!-- Instead of setting to-ports="*", administrator can use ranges and commas --> <!-- This will allow access to ports 123, 456, 457 and 458 --> <allow-access-from domain="*" to-ports="*" secure="false"/> </cross-domain-policy> 
+4
source share

All Articles