# haw to close all streams for a particular application instance

**URL:** <https://community.wowza.com/t/haw-to-close-all-streams-for-a-particular-application-instance/37022>\
**Category:** Wowza Streaming Engine\
**Created:** [November 10, 2011, 8:50am UTC](https://community.wowza.com/t/haw-to-close-all-streams-for-a-particular-application-instance/37022 "2011-11-10T08:50:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatos\_bekteshi](https://avatars.discourse-cdn.com/v4/letter/f/2acd7d/32.png) [@fatos\_bekteshi](https://community.wowza.com/u/fatos_bekteshi)\
**Post date:** [November 10, 2011, 8:50am UTC](https://community.wowza.com/t/haw-to-close-all-streams-for-a-particular-application-instance/37022/1 "2011-11-10T08:50:37Z")

</div>

Hi,

I am trying to close all streams for a praticular applicationinstance and it seems to work fine when i am publishing on rtmp but not on rtmpt

here is the code i am using:

IApplicationInstance appInstance = client.getAppInstance();

//get all the streams running on this app-instance

MediaStreamMap streamMap = appInstance.getStreams();

List streams = streamMap.getStreams();

getLogger().info(“shuting down clients connected to this appinstance:”);

Iterator streamsIterator = streams.iterator();

while(streamsIterator.hasNext() )

{

IMediaStream current\_stream = streamsIterator.next();

getLogger().info(“current\_stream Name:” + current\_stream.getName());

current\_stream.getClient().setShutdownClient(true);

}

any ideas why current\_stream.getClient().setShutdownClient(true);

is not shuting down the client that is publishing on rtmpt?

please note i am using wowza 2.

thanks

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [November 10, 2011, 5:05pm UTC](https://community.wowza.com/t/haw-to-close-all-streams-for-a-particular-application-instance/37022/2 "2011-11-10T17:05:45Z")

</div>

Probably the client is gone but not cleaned up yet by Wowza pingTimeout mechanism. I would try to handle that. RTMPT connections are more fragile.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [November 10, 2011, 8:10pm UTC](https://community.wowza.com/t/haw-to-close-all-streams-for-a-particular-application-instance/37022/3 "2011-11-10T20:10:17Z")

</div>

Your code above is closing all streams, incoming and outgoing. The ones with the first error you mentioned were probably lost Flash clients that were playing the stream. There is one stream for each client, and closing an incoming stream does not close the stream of any of the clients that were subscribed to it.

You can get just incoming streams with IApplicationInstance.getPublishStreamNames()

As for shutting down FMLE like this, I have not been able to do. FMLE just re-connects over and over. But I think it can be done with HTTP calls, at least that is what is indicated here (but that I haven’t tested):

[http://stackoverflow.com/questions/3138777/how-to-control-start-stop-encoding-flash-media-encoder-using-actionscript-3](http://stackoverflow.com/questions/3138777/how-to-control-start-stop-encoding-flash-media-encoder-using-actionscript-3)

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [November 11, 2011, 3:34pm UTC](https://community.wowza.com/t/haw-to-close-all-streams-for-a-particular-application-instance/37022/4 "2011-11-11T15:34:05Z")

</div>

Use this one:

```auto
current_stream.getClient().setShutdownClient(true);

```

Richard

---

<div class="post-metadata">

**Author:** ![fatos\_bekteshi](https://avatars.discourse-cdn.com/v4/letter/f/2acd7d/32.png) [@fatos\_bekteshi](https://community.wowza.com/u/fatos_bekteshi)\
**Post date:** [November 10, 2011, 9:18am UTC](https://community.wowza.com/t/haw-to-close-all-streams-for-a-particular-application-instance/37022/5 "2011-11-10T09:18:58Z")

</div>

I am publishing from flash media encoder (on rtmpt) and after the current\_stream.getClient().setShutdownClient(true) ;

code is executed,client is not disconnecting at all, it’s still publishing as if nothing happend.

can you please explaing a bit more on Wowza pingTimeout mechanism.

is there any example.

ideally i need to shut down the client imediately whether its rtmp or rtmpt.

thanks

---

<div class="post-metadata">

**Author:** ![fatos\_bekteshi](https://avatars.discourse-cdn.com/v4/letter/f/2acd7d/32.png) [@fatos\_bekteshi](https://community.wowza.com/u/fatos_bekteshi)\
**Post date:** [November 11, 2011, 3:23am UTC](https://community.wowza.com/t/haw-to-close-all-streams-for-a-particular-application-instance/37022/6 "2011-11-11T03:23:29Z")

</div>

can you please explain what is the difference between:

current\_stream.getClient().shutdownClient();

current\_stream.getClient().getClient().setShutdownClient(true);

current\_stream.close();

current\_stream.shutdown();

current\_stream.clear();

current\_stream.stopPublishing();

as long as the stream is stoped once, i can handle the attempt to reconnect on the server-side.

rtmpt seems to not stop becouse it relies on the http sessionID and i suppose server provides any other available connection on the pool.

so i would think that removing the session for this connection would force the client to create a new session before beign able to publish again
