# Remove invalid stream on the fly

**URL:** <https://community.wowza.com/t/remove-invalid-stream-on-the-fly/50040>\
**Category:** Wowza Developer Dojo\
**Created:** [November 2, 2017, 4:00pm UTC](https://community.wowza.com/t/remove-invalid-stream-on-the-fly/50040 "2017-11-02T16:00:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos\_Amaral](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@Carlos\_Amaral](https://community.wowza.com/u/Carlos_Amaral)\
**Post date:** [November 2, 2017, 4:00pm UTC](https://community.wowza.com/t/remove-invalid-stream-on-the-fly/50040/1 "2017-11-02T16:00:03Z")

</div>

I’ve a module that check if stream have connections and remove if it don’t receive connection by 5 minutes. I got the stream list with:

```auto
appInstance.getStreams().getPublishStreamNames()

```

But if has some invalid RTSP, it don’t come in the list, and still appears in “Application -\> Incoming Streams” waiting for stream forever, so I’ve to enter on the engine manager and remove it manually.

How can I get this invalids RTSP and remove from Incoming Streams?

---

<div class="post-metadata">

**Author:** ![Michelle\_B](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/michelle_b/32/394_2.png) [@Michelle\_B](https://community.wowza.com/u/Michelle_B)\
**Post date:** [November 10, 2017, 12:47am UTC](https://community.wowza.com/t/remove-invalid-stream-on-the-fly/50040/2 "2017-11-10T00:47:27Z")

</div>

Hi,

How is the RTSP connection initiated? Is it through the MediaCaster functionality? If so, you can use the [MediaCaster API](https://www.wowza.com/docs/how-to-mediacaster-api-to-start-native-rtp-and-mpeg-ts-streams) to disconnect the stream.

Michelle
