0 Replies Latest reply on Jun 19, 2014 6:08 AM by Lopdo

    Can't connect to host when run from web page

    Lopdo Level 1

      I have a p2p game using rtmfp protocol and cirrus server. Everything seems to be working fine when I try it in stand alone flash player, but when I embed the game to the web page, suddenly nobody can't connect to my game. There are no errors, the connection just timeouts after a while.

       

       

      here is how I create NetConnection on the host:

       

       

          netConnection = new NetConnection();

          netConnection.maxPeerConnections = 20;

          netConnection.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);

          netConnection.connect("rtmfp://p2p.rtmfp.net/3a34e[redacted]af45f80/");

       

       

       

       

          public function onNetStatus(event:NetStatusEvent) : void

          {

              var peer:P2PNetPeer = null;

              switch(event.info.code) {

                  case "NetConnection.Connect.Success":

                      streamOut = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);

                      streamOut.client = {onPeerConnect:onPeerConnect};

                      streamOut.publish(netConnection.nearID);

                  break;

          }

       

       

      It's almost same on client side, except when I get NetConnection.Connect.Success I create inStream as well:

       

       

           streamIn = new NetStream(netConnection, farId);

           streamIn.client = {msg:onMessageReceived};

           streamIn.addEventListener(NetStatusEvent.NET_STATUS, onInStreamStatus, false, 0, true);

           streamIn.play(farId);

       

       

      This inStream is the one that causes problem, it never connects to the host specified by his farId (I pair players and exchange near/farIds using my own server) if the game is run from web page. When I run it locally using stand alone player, it connects almost immediatelly.

       

       

      I am checking for other states and errors as well, but they are not important here (as said, I am not getting any errors, just timeout after a while)

       

       

      Any idea what might be going on here?