开发者

Flash not connecting via open-socket, security issue

[EDITED] This issue was originally described as my having trouble with Perl's Socket, but I have moved on now to where this is clearly a Flash security thing. However, I'm still stuck.

I have a flash client that attempts to connect to an open socket on the same host as the one on which it lives.

I am able to connect successfully from inside the Flash IDE, and when I run the swf movie locally on my machine, after granting it security clearance in the white list it connects as well. However, when I call the movie via the browser (http://m开发者_开发百科ydomain/mymovie.swf) it fails to connect.

The socket reports that a connection attempt is made but immediately disconnects.

I have a crossdomain policy file that looks like this: in the root directory of the host.

<?xml version="1.0"?>
<cross-domain-policy>
  <allow-access-from domain="*" to-ports="10005"/>
</cross-domain-policy>

(yes, the Socket is listening on that port).

In the flash movie I have a line that looks like this:

System.security.loadPolicyFile("XMLSocket://myDomain.com:80");

And I'm thinking maybe that's where the problem is, but the documentation on how to use this method is not entirely clear.

I'm in Flash CS3

All thoughts appreciated.


So, the solution appears to be that the socket server itself needs to deliver the crossdomain xml to the client.

Flash sends a string that looks like this: <policy-file-request/> right after it connects. If you respond to this with

<?xml version="1.0"?>
<cross-domain-policy>
  <allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>

It accepts the connection.

The one last remaining non-working element is that when the client is closed, it refuses to reconnect again until the server script is restarted, even though the server script appears to be willing to re-use the socket and is receiving and sending the same messages on subsequent connection requests. This problem also doesn't seem to affect the local (non hosted) version of the swf client. Very strange.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜