简体   繁体   English

Flex节点套接字连接

[英]Flex Node sockets connectivity

I am working on a Flex app using Node.JS on server side and utilizing sockets to feed my clients. 我正在使用在服务器端使用Node.JS的Flex应用程序,并利用套接字为我的客户端提供数据。 The issue is: My application works fine when I launch it from Flashbuilder, it can connect to server and feed data to my clients. 问题是:当我从Flashbuilder启动应用程序时,我的应用程序可以正常工作,它可以连接到服务器并将数据提供给客户端。 But when I try to access this app using url, it doesn't work. 但是,当我尝试使用url访问此应用程序时,它不起作用。

A quickie, Working link: D:\\Dev\\workspace\\MyProj\\bin-debug\\index.html 快速的工作链接:D:\\ Dev \\ workspace \\ MyProj \\ bin-debug \\ index.html

Not working link: (swf loads, but no data) http: //ip-address:3000/flexapp/index.html 无效的链接:(瑞士法郎加载,但没有数据)http:// ip地址:3000 / flexapp / index.html

Looks like some security issue. 看起来有些安全问题。 But I am not sure as my mind refuses to yield a solution. 但是我不确定,因为我拒绝解决。 Any help is much appreciated. 任何帮助深表感谢。

Further exploration: I tried many suggestions given over the web as follows: First, to my understanding, Socket.io itself provides you with flashpolicyfileserver at port 10843 and still I am having issues as mentioned above. 进一步的探索:我尝试了以下Web上给出的许多建议:首先,据我所知,Socket.io本身在端口10843处为您提供了flashpolicyfileserver,但仍然遇到上述问题。 Secondly, I tried running the flashpolicyserver as explained here using authbind, but still unable to resolve my issue. 其次,我试图运行flashpolicyserver作为解释这里使用authbind,但仍无法解决我的问题。

Ok I am answering my own question. 好吧,我在回答我自己的问题。 The setup that I am using is Flex4.6, Node.JS with Socket.IO, FlashSocket API 我使用的设置是Flex4.6,带有Socket.IO的Node.JS, FlashSocket API

When I faced this issue, I started correctly by specifying crossdomain.xml for my app. 遇到此问题时,我通过为我的应用程序指定crossdomain.xml来正确启动。 But that didn't worked. 但这没有用。 Then I tried using a seperate policy server at port 843, even that didn't worked. 然后,我尝试在端口843上使用单独的策略服务器,即使那没有用。 But all through this, I found that socket has been initialized and disconnected at a later point. 但是,通过所有这些,我发现套接字已在以后初始化并断开连接。 So I ended up with Flashsocket causing this issue. 所以我最终以Flashsocket导致了这个问题。 I took the source code for that and debugged. 我为此获取了源代码并进行了调试。 I found that policy URL is being generated based on the ip+host provided to it. 我发现策略URL是根据提供给它的ip + host生成的。 It's a good approach, but it simply doesn't provided any way to customize this policy URL. 这是一个好方法,但是它根本没有提供任何自定义此策略URL的方法。 What I did was just modified in such a way that I can pass my own policyURL and whenever it is passed, Flashsocket should use that otherwise, it continue to do the policyURL in old fashion. 我所做的只是以可以传递自己的policyURL的方式进行了修改,并且每当传递它时,Flashsocket都应该使用该URL,否则它将继续以旧的方式执行policyURL。 And it worked. 而且有效。

My little changes to FlashSocket: 我对FlashSocket的一些小改动:

....
private var policyURL:String;
public function FlashSocket( domain:String, protocol:String=null, proxyHost:String = null, proxyPort:int = 0, headers:String = null, policyURL:String = null)
{
....
this.policyURL = policyURL;
....
}

protected function loadDefaultPolicyFile(wsUrl:String):void {
            var policyUrl:String = "xmlsocket://" + URLUtil.getServerName(wsUrl) + ":843";
            log("policy file: " + policyUrl);
            if(policyURL){
                Security.loadPolicyFile(policyURL);
            }else}
                Security.loadPolicyFile(policyUrl);
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM