2010-12-03 90 views
0

我正在运行使用PHP的套接字服务器。套接字服务器运行良好,因为我可以使用PHP连接到它。闪存/ Flex和PHP套接字应用程序沙盒错误

现在,我有一个尝试连接到其Flash应用程序:

  this.socket.addEventListener(Event.CONNECT, onSocketConnect); 
      this.socket.addEventListener(Event.CLOSE, onSocketClose); 
      this.socket.addEventListener(IOErrorEvent.IO_ERROR, onIOError); 
      this.socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecError); 

      try { 
       this.socket.connect("myip", 9999); 
      } catch (ioError:IOError) { 
       this.debugLbl.text += "ioError1 "+ioError.message; 
      } catch (secError:SecurityError) { 
       this.debugLbl.text += "secError1 "+secError.message; 
      } 

当我在本地运行应用程序,它的工作原理!但是,当我将其上传到我的服务器时,我收到了一个沙盒安全错误(#2048)。 Flash应用程序实际上与套接字服务器位于同一台服务器上,并且存在跨域策略文件。

+0

更新:当我运行的Flash应用程序,我的服务器实际接收并接受套接字请求。但是,然后客户端/ Flash应用程序显示沙箱错误 – 2010-12-03 06:14:24

回答

0

是否需要使用php代理?我必须这样做,docd here。虽然你确实提到应用程序位于同一台服务器上,并且存在一个crossdomain.xml,所以我很可能不在那里(顺便说一句,Flash 10需要与prev版本不同的crossdomain.xml,据我所知)。

0

你实际上是在加载跨域策略文件吗?据我所知,Flash Player只会尝试自动加载以下文件:http://www.example.com/crossdomain.xml。如果你的文件是在另一个地方,你应该加载:

Security.loadPolicyFile("http://www.example.com/subfolder/crossdomain.xml"); 

而且,即使该应用程序是在同一台服务器上,Flash Player将认为“http://www.example.com”是从不同“http://example.com”,所以你应该确保你掩盖这种可能性在跨域策略文件:

<allow-access-from domain="*.example.com"/>