Skip to main content
Inspiring
October 5, 2011
Question

how to close nestream properly?

  • October 5, 2011
  • 1 reply
  • 1270 views

hello! What is the way to destroy/close netstream that was created on the fms server (4.0) and was republishing user's netstream to a netgropup (by netconnection through rtmfp)? It seams that when user stops publishing his stream and goes away, the netstream that fms was republishing to the netgroup is still active, that is way all new members of the netgroup receive PublishNotify event of the stream that is empty.

    This topic has been closed for replies.

    1 reply

    Nikhil_Kalyan
    Participating Frequently
    October 5, 2011

    Hi,

    Thanks for using RTMFP.

    On FMS 4.0, the multicast application destroys the netConnection and the netGroup that it creataed for its republishing, and hence when the original publisher stops publishing, his 'streamContext' (which includes its netConnection and its netGroup instance) is closed, virtually closing the stream.

    Other than that, any stream object can be destroyed using Stream.destroy() on the server (though this is not used in the multicast application).

    You seeing persistent connections on the multicast application after the publish stops, may be because the connection from the publisher is still maintained. Can you confirm this please?


    Thank you !

    Inspiring
    October 5, 2011

    You seeing persistent connections on the multicast application after the publish stops, may be because the connection from the publisher is still maintained. Can you confirm this please?

    Thanks for the answer. I am a little bit confused. In my case a user connects through RTMP to fms server and when he starts publishing I make one netconnection on the server (if it wasn't established before) from fms to the netgroup through RTMFP and start to republish the user's netsream to the netgroup. So if another user comes and does the same, I just make new netstream and republish his stream to a netgroup (using the same netconnection). If user goes away, I can't close the netconncetion between fms and netgroup because there could be other netsreams being republished to the netgroup. So what could be a solution, should I have the same number of netconnections to the netgroup as I have republish streams?

    If the user is trying to publish his stream again (after he has stopped publishing) with the same name, the netgroup receives NetStream.Publish.BadName event in the netgroup because there is still hanging his previous stream

    Nikhil_Kalyan
    Participating Frequently
    October 5, 2011

    Ohk, so there are two streams connecting to RTMFP in the same netGroup. NetStream.close() should work in your case I guess.

    Or, the server code can be chagned to first always make a netconnection, join to the netgroup and then using these two, make a netStream so that the stream is invalid once the netconnection and net group are destroyed.