无法连接到同一域中的套接字
我有一个 Flex Web 应用程序(编译为常规 SWF),它尝试连接到其自己的服务器上的(二进制,而不是 XML)套接字。因此,如果 swf 位于 example.com/app.swf
,则套接字为 example.com:12869
这应该是可能的,AFAIK,但是当我尝试连接时收到安全错误,指出 example.com/app.swf
无法访问 example.com:12869
。
尽管不需要它,我也有一个包含
<cross-domain-policy>
<allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>
但它没有帮助的 crossdomain.xml
文件。
我能做些什么?
您可以在此处查看该应用。
I have a Flex web app (compiled to regular SWF) that tries to connect to a (binary, not XML) socket on its own server. So if the swf is at example.com/app.swf
, the socket is example.com:12869
This should be possible, AFAIK, but when I try to connect I get a security error saying that example.com/app.swf
cannot access example.com:12869
.
Even though it shouldn't be needed, I also have a crossdomain.xml
file containing
<cross-domain-policy>
<allow-access-from domain="*" to-ports="*"/>
</cross-domain-policy>
but it doesn't help.
What can I do?
You can see the app here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是,默认情况下 Flash 会从套接字请求策略,这意味着它会将
发送到套接字 - 如果您可以将其添加到您的服务器实现,您可以看看如何实现Guy 解决了同样的问题。您还可以在启动套接字连接之前使用
Security.loadPolicyFile("http://axa3.axastudios.nl/crossdomain.xml")
来强制它首先加载您的策略。我不是 100% 确定这是否适用于 Socket 连接,文档(搜索“套接字策略文件”)有点令人困惑。The thing is that by default Flash will request the policy from the socket, meaning it sends
<policy-file-request/>
to the Socket - if you have the possibility to add it to your server implementation, you can have a look at how that guy fixed the same sort of problem.You can also use
Security.loadPolicyFile("http://axa3.axastudios.nl/crossdomain.xml")
before initiating the socket connection to force it to load your policy first. I'm not 100% sure if this works for Socket connections though, the docs (search for "Socket policy files") are slightly confusing.您可以使用我的 Apache 2 模块 - 它会监听在端口 843 并应答套接字策略请求
You could use my Apache 2 module - it listens at the port 843 and answers socket policy requests