9 Replies Latest reply on Jan 9, 2009 3:00 PM by Michael Thornburgh

    Delayed response from onPeerConnect

      Hey guys,

      I've almost finished creating a Chat Application with Stratus (just to figure it out), and I've been experiencing extremely long delays for onPeerConnect firing (and thus connecting my incoming netStreams). Is this due to Adobe's server that Stratus is housed on? Or is this like a socket connection?

      Us at Influxis are extremely interested in this technology.
        • 1. Re: Delayed response from onPeerConnect
          Michael Thornburgh Adobe Employee
          how long is "extremely long"? a few seconds, ten seconds, or tens of seconds? do you have a TURN proxy configured in your mms.cfg? do you have any NAT or firewall devices, or any local firewall software configured?


          • 2. Delayed response from onPeerConnect
            SeantronicR&D Level 1
            *Major Edit!!!!

            So, ok, the following code is working. I was adding an inNS that wasn't needed before. Do you have any thoughts about the code or anything that is jumping out at you as really wrong? I'm trying to figure out best practices for connecting with using FMS as the ID storage device (in an Array stored in a sharedObject).

            Basically what was going on, was the onPeerConnect wasn't firing, or would randomly. But now it seems that this is working a bit better. It's still slightly off, because not all clients will sync up (like on 1 out of 8 clients will be missing a connection to one of the peers). I'm thinking of checking the peerStreams.length to the array that I'm throwing all of the NetStreams into. And if they don't match up connect that one that hasn't connected yet. It's just an idea.

            Any thoughts you have on the subject would make my week. Thanks so much.

            • 3. Re: Delayed response from onPeerConnect
              AdamLane Level 1
              The "onPeerConnect" callback can be generated immediately following your call to listenerStream.publish(). This is going to be the case if you have some other stream playing that name prior to publishing, as it will want to make that onPeerConnect call prior to allowing that publisher and that player to talk with each other. I suggest moving the assignment of "listenerStream.client" to before your call to "listenerStream.publish()".
              • 4. Re: Delayed response from onPeerConnect
                Michael Thornburgh Adobe Employee
                that was the only thing i noticed, too. in my super simple test code, i set my client object (with an onPeerConnect method) before saying publish, and then it is *always* called immediately when i subscribe. i never saw a delay or a missed call.
                • 5. Re: Delayed response from onPeerConnect
                  SeantronicR&D Level 1
                  Awesome! Duh. That makes total sense. Thanks guys. That rocks.

                  • 6. Re: Delayed response from onPeerConnect
                    SeantronicR&D Level 1
                    Well, unfortunately, it's still giving me problems. Like with 5 people connected the first client will see everyone, second will connect to all but 1 maybe (that connects after he's connected), third connects to the first 2, but has problems with the 2 that connect after him. Forth will see the first one and the last one, and then the last one connected is just a mess. Is there anyway that you would like to share your super simple code that always connects? Are you connecting multiple peers? Because in most of my tests after about 3 peers connected, it gets really messy.

                    Any other tips, and if you would like to see my code, I would be more then happy to share the entire thing. It's great when it works.
                    • 7. Re: Delayed response from onPeerConnect
                      AdamLane Level 1
                      I do not see an obvious fault in the code fragment provided, but actionscript can be very asynchronous in nature. There is a maximum limit of peer connections...NetConnection.maxPeerConnections defaults to 8. It looks like you will be at that maximum with 5 clients. You may want to bump up that maximum, as each peer appears to need to serve two streams to every other peer.
                      • 8. Re: Delayed response from onPeerConnect
                        SeantronicR&D Level 1

                        That looks like that did it. I had a pretty successful test of 5 people connected. Way better then before. I'm still experiencing a slight delay having the onPeerConnect (but I'm talking maybe 15 seconds at most), but this has made it WAY more reliable. Thanks so much.

                        I also had a question for you. I've basically been going off of the code for the Sample Application that was posted. And do you have to have a listenerStream? I don't understand why I couldn't set up the onPeerConnect to the Out stream, and have that create a new In stream. But I've tried it out, and it doesn't seem to work. Oh, and does the peerStreams array get updated every time someone disconnects? Or at least set it to null, or do we have to take care of that on our end?

                        Thanks so much for the help, you've really helped me get up and running.

                        • 9. Re: Delayed response from onPeerConnect
                          Michael Thornburgh Adobe Employee
                          Sean: i just tracked down and fixed a major bug in Stratus that would account for the 15-ish second (or longer!) delays you were seeing. Please try again and let us know if it's working better for you now.

                          Please also see thread "Setup of first stream often takes upto a minute".

                          i'm sorry i didn't recognize earlier that the delay you were seeing was a bug on our end.