Skip to main content
Known Participant
March 19, 2010
Question

Reconnect to server on close

  • March 19, 2010
  • 2 replies
  • 2195 views

Hi,

I've been banging my head against the wall for a while with this problem. I'm developing a Flash application that is streaming multiple videos at the same time from Flash Media Server 3.5 over one netConnection. The connection is established when the application is initialized and after that all video player instances use the same netConnection object to connect to the media server. Initially this seemed a better way to do it, than using a separate connection for each videoplayer (I figured it would save some bandwidth even though I wasn't quite sure how much overhead does netConnection add to the stream, if any and how much more or less load does it cause to the mediaserver). It seems to work well when the connection to the server is fast and stable. However on slower and more unstable connections, the netConnection starts breaking up. And new netConnection can't be established in netStatusEvent handler.

So my main problem now is that when the connection is closed, all the streams obviously stop and you'll have reload the application/web page to re-establish the netConnection (not very user friendly). So I've been wondering what my options are. Should I use separated connection for each stream and maybe even start using the FLVPlayback component in Flash instead of the built-in Video class. Or is there some way to reconnect a closed netconnection and resume the streams from where they were left when the connection suddenly closed?

    This topic has been closed for replies.

    2 replies

    March 19, 2010

    Hi teel,

    Are you facing any network glitches which may be affecting you netconnection? We could also check the access.00.log on your fms server to know why the conenctions might be getting dropped from the details logged there. You could enable all the events and fields in access.00.log before you run your test

    In FMS install directory/conf/Logger.xml

    Under the nodes <Logger><Access> modify to <Events>*</Events> & <Fields>*</Fields>

    This will enable all the details. So when you run the test and see the connections getting dropped we might try to find some clue in access.00.log.

    Now if there were really some network glitches and due to which the connections don't end up being stable you could use the new Stream Reconnect feature available in FMS 3.5.3 with Flash Player 10.1.

    With this feature you can make use of the existing netstream objects and attach them to the reconnected netconnection and obtain a seamless playback.

    Check out more details about the feature on http://help.adobe.com/en_US/FlashMediaServer/3.5.3/FeaturesGuide/flashmediaserver_3.5.3_features.pdf

    You could get the FMS 3.5.3 from http://www.adobe.com/support/flashmediaserver/downloads_updaters.html. Flash Player 10.1 is currently in Beta  ( http://labs.adobe.com/downloads/flashplayer10.html ) and will be released soon.

    Thanks

    Mamata

    teel_Author
    Known Participant
    March 19, 2010

    Thanks for your replies. Unfortunately I'm targeting this app for Flash Player 9, so I'm missing some nice features from FP10(.1). This happens almost always on slow connections. I've tested this by limiting my bandwidth to 512kbps with NetLimiter and it disconnects almost immedately when I start streaming the videos (there's 6 simultaneous videos altogether). Our testers have also faced this problem when using unstable/slow network. I guess digging through the logs is my next step, but that'll have wait until next week.

    If I would use the method JayCharles descibes, what would be the best way to handle it with NetStreams? As far as I know, NetStream is closed immediately when NetConnection is lost. If I reconnect the same instance of NetConnection to the same server, does NetStream detect the connection is active again, or do I need to create a new NetStream or manually connect the old NetStream again when connection is established to resume the video from where it was left when the connection closed?

    teel_Author
    Known Participant
    April 13, 2010

    Hmm, when there was only one subscriber when you saw connection getting closed, if you made another subscriber to connect would it also get disconnected in simialr way?

    And I think you did mention there was no specific clue in core.00.log or master.00.log.

    Would you be able to send me your client side code so that I can take a look at it?

    Thanks

    Mamata


    Another client would disconnect as well, if it didn't have enough bandwidth. However if the client's bandwidth is big enough, there's no problems. The server's resources are nowhere near to its limits. Unfortunately I can't share my clientside code, because it's a part of a big project.

    I think I'll just have to live with the fact that the site will not be very accessible for users with ancient network connections. There's really no point in spending much more time for this problem.

    I appreciate you trying to help me solve this, so thanks.

    March 19, 2010

    I'd continue to use the same netconnection for both streams.

    You're right about the not being able to reestablish the netconnection from within the netstatus handler. What you can do is dispatch another event in your netstatus event handler in response to the NetConnection.Connect.Close status, and let another method or class handle the reconnect.