# How to control access to an RTSP/RTP stream

**URL:** <https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [December 3, 2009, 10:09am UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69 "2009-12-03T10:09:10Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)\
**Post date:** [December 3, 2009, 10:09am UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/1 "2009-12-03T10:09:10Z")

</div>

[https://www.wowza.com/docs/how-to-control-access-to-rtsp-rtp-streams](https://www.wowza.com/docs/how-to-control-access-to-rtsp-rtp-streams)

---

<div class="post-metadata">

**Author:** ![Hiten\_Gajjar](https://avatars.discourse-cdn.com/v4/letter/h/ba9def/32.png) [@Hiten\_Gajjar](https://community.wowza.com/u/Hiten_Gajjar)\
**Post date:** [April 13, 2010, 10:53am UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/2 "2010-04-13T10:53:58Z")

</div>

Is onRTPSessionCreate() part of some patch on top of Wowza Pro 2.0.0.0?

---

<div class="post-metadata">

**Author:** ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)\
**Post date:** [May 25, 2010, 11:35am UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/3 "2010-05-25T11:35:52Z")

</div>

If you start a stream using StartupStreams.xml it will continue to try to connect to the source as long as the server is running. You have locked the stream server-side so it will continue to try to connect to it. You can use the IApplicationInstance.stopMediaCasterStream method to stop the stream or you can stop it using the Stream Manager (http://[wowza-ip-address]:8086/streammanager) or through the JMX command line interface or the SOAP interface (lots of options).

Charlie

---

<div class="post-metadata">

**Author:** ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)\
**Post date:** [August 3, 2010, 4:13am UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/4 "2010-08-03T04:13:10Z")

</div>

We do not have a way to re-write URLs like this. If the key is after the application and appInstance name then you can rewrite the URL by overriding the play command. The basic URL structure is:

rtmp://[domain]/[application]/[appInstance]/[stream-path-and-name]

You can do anything you like to re-write the [stream-path-and-name] part. The first 3 bits are required.

So you can more your security key. The URL would be more like:

rtmp://localhost:1935/vod/_definst_/MjIhMTI4MDgyMjM5MyEzNjAwIVghZXVyb25/Extremists.flv

Charlie

---

<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:** [April 13, 2010, 12:55pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/5 "2010-04-13T12:55:34Z")

</div>

I don’t think so, it should be in Wowza 2.0.0.0

But it’s a good idea to apply the latest patch. There are rtsp related fixes and enhancements in recent patch releases:

[http://wowza.com/devbuild.html](http://wowza.com/devbuild.html)

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:** [July 19, 2010, 11:51am UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/6 "2010-07-19T11:51:13Z")

</div>

Use onRTPSessionCreate instead of onConnect. See this post:

[http://community.wowza.com/t/-/69](http://community.wowza.com/t/-/69)

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:** [July 19, 2010, 4:39pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/7 "2010-07-19T16:39:43Z")

</div>

onRTPSessionCreate fires when you start playing a stream from an RTSP device or player. For example VLC using a rtsp url to a Wowza Stream.

You can add a querystring to the rtsp url and retrieve in onRTPSessionCreate with:

```auto
String queryStr = rtpSession.getQueryStr();

```

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:** [July 20, 2010, 8:24pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/8 "2010-07-20T20:24:02Z")

</div>

You need an application named myModules, and you need to an Application.xml file with at least one modification, and you need to include a stream name.

Call the application “vod”, and create it by adding this folder:

/applications/vod

To configure it by adding this folder:

/conf/vod

Then copy /conf/Application.xml to /conf/vod/Application.xml

Make one edit in the new file: Change /RTP /Authentication /PlayMethod from “default” to “none”

Now play this in VLC:

rtsp://[wowza-address]:1935/vod/sample.mp4

This will run onRTPSessionCreate

You should go through the quickstart, User Guide and various tutorials on this forum

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:** [August 2, 2010, 2:28pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/9 "2010-08-02T14:28:33Z")

</div>

RTMP connection will not trigger onRTPSessionCreate because it’s not an RTP session. RTMP connection triggers onConnect

```auto
public void onConnect(IClient client, RequestFunction function,
			AMFDataList params) {
		getLogger().info("onConnect: " + client.getClientId());
	}

```

HTTP session: onHTTPSessionCreate

RTP session: onRTPSessionCreate

RTMP connection: onConnect

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:** [August 2, 2010, 2:32pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/10 "2010-08-02T14:32:26Z")

</div>

btw, you have past the scope of the “quickstart” guide. There is more in depth information in the sticky posts of the Helpful Hints, Useful Code Forum section:

[http://community.wowza.com/c/-/10](http://community.wowza.com/c/-/10)

There is a lot to digest.

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:** [August 2, 2010, 2:48pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/11 "2010-08-02T14:48:25Z")

</div>

I accidentally copied in onConnectReject above, but corrected it to onConnect

Richard

---

<div class="post-metadata">

**Author:** ![miguel\_barros](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@miguel\_barros](https://community.wowza.com/u/miguel_barros)\
**Post date:** [May 25, 2010, 6:05pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/12 "2010-05-25T18:05:23Z")

</div>

Hi,

If the session is started in the StartupStreams.xml, the method rtpSession.rejectSession(); don’t stop the auto-reconnection(the rtsp session will automatically start if you use limited rtsp sessions) of session (i tested)…

Some one know another way stop the auto-reconnection in rtsp sessions?

thank you,

barros

---

<div class="post-metadata">

**Author:** ![Aydin\_Gungordu](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Aydin\_Gungordu](https://community.wowza.com/u/Aydin_Gungordu)\
**Post date:** [July 19, 2010, 12:49pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/13 "2010-07-19T12:49:14Z")

</div>

Hi everyone,

I’m very new to working with Wowza, so please bear with me.

We’re trying to control access in a different way from what is being discussed in this thread. We want to include a key parameter in the RTSP link, and then do some checks with some sort of plugin before allowing access.

So I suppose the link would be something like this:

RTSP:///&key=1234

I am working with a sample module:

```auto
public class MyFirstModule extends ModuleBase {
public void onConnect(IClient client, RequestFunction function,AMFDataList params) {
//my code is here
}

```

I can trigger this by opening MyFirstModule.html in a browser, but I cannot add any parameters to it that way. It calls the onConnect method with “RTMP://localhost/mymodules”.

I’ve read the quick start guide, the javadoc, and all the other documentation I could find, but I’m still struggling to get started with this.

So I have several questions:

- Am I on the right track using the onConnect method for this?

- How can I test what I have done so far? I.e. how can I put a key in the URL?

- Is what I am trying to do feasible?

- Is there some architectural overview of how things work in Wowza? Some UML diagrams showing the sequence of events when a request comes from a client, would be very useful.

Thanks in advance for your help.

---

<div class="post-metadata">

**Author:** ![Aydin\_Gungordu](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Aydin\_Gungordu](https://community.wowza.com/u/Aydin_Gungordu)\
**Post date:** [July 19, 2010, 4:00pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/14 "2010-07-19T16:00:18Z")

</div>

How and when is onRTPSessionCreate triggered? I never get into that method.

What about adding parameters to the URL?

---

<div class="post-metadata">

**Author:** ![Aydin\_Gungordu](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Aydin\_Gungordu](https://community.wowza.com/u/Aydin_Gungordu)\
**Post date:** [July 20, 2010, 12:33pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/15 "2010-07-20T12:33:12Z")

</div>

I tried this in VLC:

rtsp://localhost:1935/mymodules

VLC gives the following error:

VLC is unable to open the MRL ‘rtsp://localhost:1935/mymodules’. Check the log for details.

Wowza only logs the following:

WARN server comment - Application folder ([install-location]/applications/_defapp_) is missing

It doesn’t trigger anything in my module.

😕

---

<div class="post-metadata">

**Author:** ![Aydin\_Gungordu](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Aydin\_Gungordu](https://community.wowza.com/u/Aydin_Gungordu)\
**Post date:** [August 2, 2010, 3:09pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/16 "2010-08-02T15:09:54Z")

</div>

Hi,

If I use VLC player to open:

“rtsp://localhost:1935/vod/sample.mp4”

Then RTPSessionCreate is triggered, and it executes my code as intended. 🙂

However, if I use FLV player to open:

rtmp://localhost:1935/vod/Extremists.flv

The video just plays, and RTPSessionCreate is never triggered, my code never runs, and that is not good. :mad:

I would therefore reiterate my request to know what is triggered when, and how, and why. Or at this stage, I will gladly settle for any pointers that would get this working properly.

I just need my code to be triggered whenever anybody anywhere tries to play any clip or anything else, in any way shape or form, on my wowza server. Shirley this shouldn’t be so hard. 😕

Again, I have read every word in the quickstart guide 3 times, and followed instructions to a T.

---

<div class="post-metadata">

**Author:** ![Aydin\_Gungordu](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Aydin\_Gungordu](https://community.wowza.com/u/Aydin_Gungordu)\
**Post date:** [August 2, 2010, 3:44pm UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/17 "2010-08-02T15:44:30Z")

</div>

Ohhhh… now that makes sense.

Shows how much I know about this stuff :rolleyes:

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![Aydin\_Gungordu](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@Aydin\_Gungordu](https://community.wowza.com/u/Aydin_Gungordu)\
**Post date:** [August 3, 2010, 10:58am UTC](https://community.wowza.com/t/how-to-control-access-to-an-rtsp-rtp-stream/69/18 "2010-08-03T10:58:05Z")

</div>

Quick question

If the client tries to open the following URI (in VLC player)

rtmp://localhost:1935/MjIhMTI4MDgyMjM5MyEzNjAwIVghZXVyb25/vod/Extremists.flv

it will fail because the key is there in the URI, so it looks for the file in the wrong place.

How can I tell Wowza to ignore the key, and just treat it like

rtmp://localhost:1935/vod/Extremists.flv

Should calling client.setUri() do it? Or what would you suggest?
