繁体   English   中英

RTMFP直接对等连接在Windows XP上有效,但在Windows 7上不可用

[英]RTMFP direct peer-to-peer connection working on Windows XP, but not on Windows 7

我们这里的一个项目有一个奇怪的问题。 当我们将NetConnection与NetGroup结合使用来启动Windows XP上的两个本地AIR应用程序之间的通信时,它们始终总是成功连接到NetGroup,并且彼此检测为邻居。 但是,在Windows 7上,两个应用程序都成功连接到NetConnection,而NetGroup都没有将彼此检测为邻居。

要重现此问题,这里有两个AIR应用程序:

RTMFP1:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
applicationComplete="init()">
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->

</fx:Declarations>
<fx:Script>
    <![CDATA[
        private var nc:NetConnection;

        private var group:NetGroup;

        [Bindable]
        private var connected:Boolean = false;


        private function init():void
        {
            connect();
        }

        private function connect():void
        {
            nc = new NetConnection();
            nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
            nc.connect("rtmfp:");
        }

        private function netStatus(event:NetStatusEvent):void
        {
            writeText(event.info.code);

            switch (event.info.code)
            {
                case "NetConnection.Connect.Success":
                    setupGroup();
                    break;

                case "NetGroup.Connect.Success":
                    connected = true;
                    break;

                case "NetGroup.Posting.Notify":
                    receiveMessage(event.info.message)
                    break;
            }
        }

        private function setupGroup():void
        {
            var groupspec:GroupSpecifier = new GroupSpecifier("myGroup/groupOne");
            groupspec.postingEnabled = true;
            groupspec.ipMulticastMemberUpdatesEnabled = true;
            groupspec.addIPMulticastAddress("127.0.0.1:30302");

            group = new NetGroup(nc, groupspec.groupspecWithAuthorizations());
            group.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
        }

        private var i:int = 0;

        private function sendMessage():void
        {
            var message:Object = new Object();
            message.sender = group.convertPeerIDToGroupAddress(nc.nearID);
            message.text = "Here's your message!";
            message.random = i++;
            group.post(message);
        }

        public function receiveMessage(message:Object):void
        {
            writeText(message.text);
        }

        private function writeText(txt:String):void
        {
            txtHistory.text += txt + "\n";
        }


        private function btnSend_clickHandler(event:MouseEvent):void
        {
            sendMessage();
        }
    ]]>
</fx:Script>
<s:layout>
    <s:VerticalLayout/>
</s:layout>
<s:TextArea id="txtHistory"
    width="100%" height="100%"/>
<s:Button id="btnSend"
    enabled="{connected}"
    label="Send message"
    click="btnSend_clickHandler(event)"/>
</s:WindowedApplication>

RTMFP2:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
applicationComplete="connect()">
<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
    <![CDATA[
        private var nc:NetConnection;

        private var group:NetGroup;

        [Bindable]
        private var connected:Boolean = false;


        private function connect():void
        {
            nc = new NetConnection();
            nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
            nc.connect("rtmfp:");

        }

        private function netStatus(event:NetStatusEvent):void
        {
            switch (event.info.code)
            {
                case "NetConnection.Connect.Success":
                    setupGroup();
                    break;

                case "NetGroup.Connect.Success":
                    connected = true;
                    break;

                case "NetGroup.Posting.Notify":
                    receiveMessage(event.info.message)
                    break;
            }
        }

        private function setupGroup():void
        {
            var groupspec:GroupSpecifier = new GroupSpecifier("myGroup/groupOne");
            groupspec.postingEnabled = true;
            groupspec.ipMulticastMemberUpdatesEnabled = true;
            groupspec.addIPMulticastAddress("127.0.0.1:30302");

            group = new NetGroup(nc, groupspec.groupspecWithAuthorizations());
            group.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
        }

        private var i:int = 0;

        private function sendAcknowledge():void
        {
            var message:Object = new Object();
            message.text = "We received your message!";
            message.sender = group.convertPeerIDToGroupAddress(nc.nearID);
            message.sequence = i++;
            group.post(message);
        }

        public function receiveMessage(message:Object):void
        {
            writeText(message.text);
            sendAcknowledge();
        }

        private function writeText(txt:String):void
        {
            textArea.text += txt + "\n";
        }
    ]]>
</fx:Script>
<s:layout>
    <s:VerticalLayout/>
</s:layout>
<s:TextArea id="textArea" width="100%" height="100%"/>
</s:WindowedApplication>

在Windows XP上,这些应用程序可以相互连接并相互发送消息。 但是,在Windows 7上,它们不能。

有谁知道为什么这在Windows 7上不起作用以及可以采取哪些步骤使其起作用? 这对我们的项目至关重要。

Ps:在某些情况下,应用程序需要很长的时间才能将彼此检测为邻居(在某些情况下最多需要15秒),在其他情况下,它们会立即相互检测到。 有谁知道会导致这种延迟的原因吗?

我的第一个猜测可能是与防火墙或网络有关。 RTMFP使用非标准的UDP端口1935 ,许多企业防火墙阻止了不是端口80或443(HTTP,HTTPS)的所有内容。

这就是为什么建议您在p2p无法正常工作时进行第三方服务器回退的原因,因为这种情况并非总是如此。

暂无
暂无

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

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