Wowza Community

how to stop streaming using Wowza RestAPIs?

Hello there,

I am trying to build a live stream application using WOWZA, but I am facing a problem in finishing/ending/stopping/ deleting the stream.

using the RestAPI’s described in the REST API Documentation I am able for example to retrieve publishers list using the following API:

Note: following APIs written in python-flask application.

URL_RETRIEVE_PUBLISHERS_LIST = "http://{}:{}/v2/servers/{}/vhosts/{}/applications/{}/publishers".format(settings.WSE_IP, settings.WSE_SERVER_PORT, settings.WSE_SERVER_NAME, settings.WSE_VHOST_NAME, settings.WSE_LIVE_APP_NAME)
response = requests.get(URL_RETRIEVE_PUBLISHERS_LIST,auth=(settings.WOWZA_USERNAME, settings.WOWZA_PASSWORD))

I used disconnect stream API to disconnect the stream, as follows:

URL_DISCONNECT_STREAM_WITH_STREAM_KEY = "http://{}:{}/v2/servers/{}/vhosts/{}/applications/{}/instances/{}/incomingstreams/{}/actions/0".format(
    settings.WSE_IP, settings.WSE_SERVER_PORT, settings.WSE_SERVER_NAME, settings.WSE_VHOST_NAME,
    settings.WSE_LIVE_APP_NAME, instanceName, stream_key)

and got the following response:

<response[200]>: content: b'<?xml version="1.0" encoding="UTF-8" ?>\n<wmsResponse>\n  <success>false</success>\n  <message>Unknown action: 0</message>\n</wmsResponse>'

when I change the action in the API to disconnectStream except of “0”: I get <response[404]>

I’ve used as well the http stream control plugin, following is it’s link: how-to-control-stream-class-streams-dynamically-httpstreamcontrol

following is the API used to call the stop_stream action:

URL_DISCONNECT_STREAM_WITH_STREAM_KEY = "http://{}:8086/streamcontrol?appName={}&action=stopStream&streamName={}".format(settings.WSE_IP, settings.WSE_LIVE_APP_NAME, stream_key)
response = requests.get(URL_DISCONNECT_STREAM_WITH_STREAM_KEY, auth=(settings.WOWZA_USERNAME,settings.WOWZA_PASSWORD))

it returns

<response[200]>: content: b'<html><head><title>Wowza Streaming Engine 4 Developer Edition (Expires: Dec 17, 2020) 4.8.5 build20200616153358</title></head><body>Wowza Streaming Engine 4 Developer Edition (Expires: Dec 17, 2020) 4.8.5 build20200616153358</body></html>'

but without ending the specified stream.

my question is : how can I end/finish/stop the stream using an API, so that I can activate the onStreamDestroy/onDisconnect event in my WowzaJavaModule?

All what I need to do is to end the stream so that the events in my WowzaJavaModule start!

any suggestion would be highly appriciated.

thanks in advanced


Try running your query on port 8087 instead of 8086. I get the same behavior on 8086, 200 with my Engine build configuration, which appears to be expected behavior (1935 does the same thing).

I would also recommend using curl or Postman to test your queries to make sure your Python code is behaving as you expect it.

Please see this post for additional information.

You can submit a support ticket if you still need help with stopping the stream when the viewer clicks ‘Finish’.