5
votes

I have found a lot of similar posts here, but none seem to address the exact issue I'm having.

I am just trying to connect an XMLSocket to my server, and about 10 seconds after I attempt to connect, I get a SecurityErrorEvent: Error #2048: Security sandbox violation (cannotload data from ##.##.##.##:9024).

Server-side, I have a php script that listens for port 9024. I'm pretty sure that is working right, because I can connect to it using other php scripts. Also, when my client-side php makes the policy-file request, my server script returns the policy. Here's the as3:

private var sock:XMLSocket  = new XMLSocket();

// in my connection method
Security.allowDomain("domain.com");
Security.loadPolicyFile("dubDomain.domain.com/crossdomain.xml");
Security.loadPolicyFile("xmlsocket://domain.com:9024");
sock.connect("11.11.11.11", 9024);

I set listeners to the socket in as3 before calling sock.connect, but I think whatever goes wrong happens before they would be triggered.

My understanding is that at either the second Security.loadPolicyFile, or the socket.connect should attempt to connect to the server at socket 9024 and request a policy file. I believe sock.connect would only send the request after it fails to get a response from port 843.

On the server end, though, it shows no attempt is ever made to connect. I have tried this from the IDE(FlashDevelop), and from the swf when uploaded to the server.

I would try it on port 843, but I don't have admin rights on my server. If it matters, here is a bit of the php script:

$client = socket_accept($sock);
if (socket_getpeername($client, $address, $theirport))
{
echo "Client $address: $theirport is now connected to us\n";
}
$input = socket_read($client, 1024000);
echo "[client] $input";

$sock seems to be set up fine, as I can connect using another php script, but it just waits forever when I try to connect with as3.

Any suggestions? Am I misunderstanding something? Thanks in advance.

1

1 Answers

0
votes
Security.loadPolicyFile("subDomain.domain.com/crossdomain.xml");
sock.connect("11.11.11.11", 9024);

You are requesting a crossdomain file for a subdomain. It will allow you, at max, to connect to the subdomain.domain.com. It absolutly can't allow you to connect to domain.com.

What will the XMLSocket do, is load the crossdomain where it thinks it can be, related to the host ip you gave it. That will be first at 11.11.11.11/crossdomain.xml. If it can't found it, it will try to access 11.11.11.11:843. It that fails, you will have a Security Error thrown.

So, you either need to connect directly to your subdomain :

 sock.connect("subDomain.domain.com", 9024);

Or to add a crossdomain.xml which allows you to connect on 11.11.11.11:9024, on 11.11.11.11/crossdomain.xml :

<allow-access-from domain="YOURSWFDOMAIN" to-ports="9024"/>

Then, you will receive a request from flash on your server. You're good to go then.