1 Reply Latest reply on Feb 29, 2012 11:14 PM by Ventis85

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

    Ventis85 Level 1

      Hi all,

       

      we're having a strange problem on a project here. When we use NetConnection in combination with a NetGroup to initiate communication between two local AIR applications on Windows XP,  they always both connect to the NetGroup succesfully and detect each other as neighbors. However, on Windows 7 both applications connect succesfully to the NetConnection and NetGroup both don't detect each other as neighbors.

       

      To reproduce this problem, here are two AIR applications:

       

      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>
      

       

       

      These applications can connect and send message to each other without a problem on Windows XP. On Windows 7 however, they cannot.

       

      Does anyone know why this wouldn't work on Windows 7 and what steps can be taken to make it work? It's critical to our project that this works.

       

      P.s.: In some cases, the applications take quite a long time to detect each other as neighbors (up to  15 seconds in some cases), in other cases they detect each other immediately. Does anyone know what could cause this delay?