私は途方に暮れています。Flashがポリシーファイルを正しくロードしていない理由がわかりません。私はこれをフラッシュデバッガーからテストしています。
I've also tried from http://127.0.0.1:80/game (it sends a request to http://127.0.0.1:3014/socket.io/1/).
Security.loadPolicyFile('xmlsocket://127.0.0.1:843'); var r:URLRequest = new URLRequest(); r.url = httpProtocal+"://" + domain + "/socket.io/1/?time=" + new Date().getTime(); r.method = URLRequestMethod.POST; var ul:URLLoader = new URLLoader(r); ul.addEventListener(Event.COMPLETE, onDiscover); ul.addEventListener(HTTPStatusEvent.HTTP_STATUS, onDiscoverError); ul.addEventListener(IOErrorEvent.IO_ERROR , onDiscoverError);
エラー:
> webSocketLog: policy file: xmlsocket://127.0.0.1:843 Error #2044:
> Unhandled securityError:. text=Error #2048: Security sandbox
> violation: file:///ude/game/bin-release/Game.swf cannot load data from
> http://127.0.0.1:3014/socket.io/1/?time=1359025067289. at
> com.pnwrain.flashsocket::FlashSocket()
しかし、これは機能します:
> echo -ne '<policy-file-request/>\0' | nc -v 127.0.0.1 843
Connection to 127.0.0.1 843 port [tcp/*] succeeded!
<?xml version='1.0' ?>
<!DOCTYPE cross-domain-policy SYSTEM 'http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd'>
<cross-domain-policy>
<allow-access-from domain='*' to-ports='*' />
</cross-domain-policy>
crossdomain.xmlへの絶対パスの指定も機能しません。このファイルをブラウザにロードできます。
> webSocketLog: policy file: http://127.0.0.1:843/crossdomain.xml
> Error #2044: Unhandled securityError:. text=Error #2048: Security
> sandbox violation: file:///ude/game/bin-release/Game.swf cannot load
> data from http://127.0.0.1:3014/socket.io/1/?time=1359025126138. at
> com.pnwrain.flashsocket::FlashSocket()
これでも機能しません(非常に人気のあるブログ投稿からの解決策):
import flash.system.Security;
Security.allowDomain("http://127.0.0.1");
デバッガポリシーファイルのログは次のとおりです。
> OK: Root-level SWF loaded:
> file:///ude/game/bin-release/Game.swf
> OK: Searching for <allow-access-from> in policy files to authorize
> data loading from resource at
> http://127.0.0.1:3014/socket.io/1/?time=1359026453454 by requestor
> from
> file:///ude/game/bin-release/Game.swf
> Error: [strict] Ignoring policy file at
> http://127.0.0.1:3014/crossdomain.xml due to missing Content-Type.
> See http://www.adobe.com/go/strict_policy_files to fix this problem.
> Error: Request for resource at
> http://127.0.0.1:3014/socket.io/1/?time=1359026453454 by requestor
> from
> file:///ude/game/bin-release/Game.swf
> is denied due to lack of policy file permissions. Warning: HTTP
> response headers not available on this platform. Strict policy file
> rules cannot be enforced. OK: Policy file accepted:
> http://127.0.0.1:843/crossdomain.xml
ここで興味深いのはOK: Policy file accepted
、私が呼び出しているにもかかわらず、メッセージがエラーの後に来ることです。
Security.loadPolicyFile('http://127.0.0.1:843/crossdomain.xml');
の前にURLRequest
。そこでURLRequest
、をsetTimeoutに移動すると、ログに次のように表示されます。
> OK: Root-level SWF loaded:
> file:///ude/game/bin-release/Game.swf
> Warning: HTTP response headers not available on this platform. Strict
> policy file rules cannot be enforced. OK: Policy file accepted:
> http://127.0.0.1:843/crossdomain.xml OK: Searching for
> <allow-access-from> in policy files to authorize data loading from
> resource at http://127.0.0.1:3014/socket.io/1/?time=1359028255268 by
> requestor from
> file:///ude/game/bin-release/Game.swf
> Error: [strict] Ignoring policy file at
> http://127.0.0.1:3014/crossdomain.xml due to missing Content-Type.
> See http://www.adobe.com/go/strict_policy_files to fix this problem.
したがって、843ポリシーファイルは正常にロードされたようですが、ポート3014ポリシーファイルをロードしようとします(サブポリシーファイルをチェックしている可能性がありますか?)。これは、「Welcometosocket.io」というsocket.ioHTMLページです。そのために失敗するはずはないようです。
デバッガーアラートでこれを受け取ります:
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: file:///ude/game/bin-release/Game.swf cannot load data from http://127.0.0.1:3014/socket.io/1/?time=1359028255268.
at MethodInfo-3642()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at SetIntervalTimer/onTimer()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
どんなアイデアでも大歓迎です。ありがとうございました!