# How to invoke an external URL to notify events like onPlay, onDescribe, onTearDown.

**URL:** <https://community.wowza.com/t/how-to-invoke-an-external-url-to-notify-events-like-onplay-ondescribe-onteardown/41102>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [November 12, 2014, 3:44pm UTC](https://community.wowza.com/t/how-to-invoke-an-external-url-to-notify-events-like-onplay-ondescribe-onteardown/41102 "2014-11-12T15:44:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gollapudi\_Sridhar](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Gollapudi\_Sridhar](https://community.wowza.com/u/Gollapudi_Sridhar)\
**Post date:** [November 12, 2014, 3:44pm UTC](https://community.wowza.com/t/how-to-invoke-an-external-url-to-notify-events-like-onplay-ondescribe-onteardown/41102/1 "2014-11-12T15:44:58Z")

</div>

Hi,

How can i invoke an external URL (over http to notify the events) during various events like onPlay, onPause, onTearDown(), onDescribe, onAnounce() etc. Please share me a module code snippet.

Thanks in Advance.

---

<div class="post-metadata">

**Author:** ![Karel\_Boek](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/karel_boek/32/454_2.png) [@Karel\_Boek](https://community.wowza.com/u/Karel_Boek)\
**Post date:** [November 12, 2014, 12:46pm UTC](https://community.wowza.com/t/how-to-invoke-an-external-url-to-notify-events-like-onplay-ondescribe-onteardown/41102/2 "2014-11-12T12:46:00Z")

</div>

Hi,

Use the org.apache.http.client.HttpClient. Make sure you use the correct version of the library, as Wowza uses this library too, and using a different version than Wowza does, will cause a conflict. If I’m correct, it’s version 3.1 you must use (at least that version works for me).

```auto
String url = "http://my.external.url";
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(url);
// You can use com.google.gson.Gson to send JSON formatted data to your server
Gson gson = new Gson();
String json = gson.toJson(myObjectWithSerializableData);
StringEntity params = new StringEntity(json);
request.addHeader("content-type", "application/x-www-form-urlencoded");
request.setEntity(params);
HttpResponse response = client.execute(request);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
String data = "";
while ((line = reader.readLine()) != null) {
    data += line;
}
// Parse the response to an object, assumed that you get a response, and that it's JSON formatted
MyResponseObject respObj = gson.fromJson(data, MyResponseObject.class);

```

---

<div class="post-metadata">

**Author:** ![Karel\_Boek](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/karel_boek/32/454_2.png) [@Karel\_Boek](https://community.wowza.com/u/Karel_Boek)\
**Post date:** [November 12, 2014, 8:15pm UTC](https://community.wowza.com/t/how-to-invoke-an-external-url-to-notify-events-like-onplay-ondescribe-onteardown/41102/3 "2014-11-12T20:15:19Z")

</div>

This is a synchronous call, so the HttpClient.execute will block and wait for response, so yes, the HttpResponse will always correspond to the HttpPost request.

---

<div class="post-metadata">

**Author:** ![Gollapudi\_Sridhar](https://avatars.discourse-cdn.com/v4/letter/g/8edcca/32.png) [@Gollapudi\_Sridhar](https://community.wowza.com/u/Gollapudi_Sridhar)\
**Post date:** [November 13, 2014, 12:08am UTC](https://community.wowza.com/t/how-to-invoke-an-external-url-to-notify-events-like-onplay-ondescribe-onteardown/41102/4 "2014-11-13T00:08:03Z")

</div>

Hi karelboek,

Thanks a lot for your response. I still have a small concern. If i have n number of RTSP sessions simultaneously, does the above code work. My concern is the stream which has invoked the http url should able to get the corresponding response. Will it work ?
