RTSP Stream Still Playing from Source After Disconnect

Discussion in 'Web Call Server 5' started by Matthew Alan Gray, Jul 25, 2017.

  1. Matthew Alan Gray

    Matthew Alan Gray New Member

    We currently have a single WCS server up on an EC2 instance, and we use it to connect to external RTSP streams and stream the resulting video over WebRTC. The problem is, once we stop streaming over WebRTC, the RTSP stream may still be active. Is there any way to ensure that the RTSP stream can and will be terminated after the WebRTC stream is no longer being subscribed to?
  2. Max

    Max Administrator Staff Member

    There is a timeout, about 1 minute.
    If no new subscribers, RTSP stream will be terminated.

    You can control this using REST API:

    Request
    Code:
    POST /rest-api/rtsp/find_all HTTP/1.1
    Host: 192.168.1.101:9091
    Content-Length: 0
    Content-Type: application/json
    Response
    Code:
    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Content-Type: application/json;charset=UTF-8
    Date: Tue, 28 Mar 2017 14:47:08 GMT
    [{
    "uri":"rtsp://s1.media-planet.sk:80/live/bardejov1","status":"PLAYING"
    },{
    "uri":"rtsp://str81.creacast.com/grandlilletv/high","status":"PLAYING"
    }]
    REST API docs
    https://flashphoner.com/docs/wcs5/wcs_docs/html/en/wcs-rest-api/
  3. Matthew Alan Gray

    Matthew Alan Gray New Member

    Yes, I realize that there is supposed to be a timeout, but it's not timing out after 1 minute like it is supposed to. I have verified that the destination for the RTSP stream is the WCS server instance, and we have had situations where the RTSP video continued to stream for hours. At present, we have a cron job that runs at the top of every hour that simply restarts the WCS service on the EC2 instance, and this terminates the streams when it is executed. However, this is not the desired approach and is in place as a short term solution in order to save on bandwidth.
  4. Max

    Max Administrator Staff Member

    You can fix this by two ways

    1. Update to the latest available build 2358
    Code:
    service webcallserver update
    There is a chance it is fixed in the latest builds.

    2. Use REST API method
    You can terminate particular RTSP stream and avoid WCS server restart.
    Code:
    /rest-api/rtsp/terminate
    {
    "uri":"rtsp://yourhost:554/live.sdp"
    }
  5. Matthew Alan Gray

    Matthew Alan Gray New Member

    The RESTful API works fine for terminating it from the client side, but the 1 minute timeout for RTSP streams is not occurring. In a perfect world, we will always be able to explicitly terminate the RTSP connection after someone stops viewing a stream - however, networking and software errors occur that can prevent that call from being made and having the working 1 minute timeout would be ideal as a redundant way to ensure the RTSP stream is not running when it is not used.
  6. Max

    Max Administrator Staff Member

    Could you help to reproduce this?
    This is what I do
    1. I open player
    https://wcs5-eu.flashphoner.com/dashboard.xhtml?demo2=demo2/player
    2. I'm playing RTSP stream.
    3. Checking traffic.
    tcpdump -s 4096 -w log.pcap
    I see a lot of RTSP video traffic
    4. I close Chrome browser.
    Checking traffic again.
    It is clear. No RTSP traffic captured.

    So it works like a charm for me. RTSP session is terminated automatically.
    I'm using Chrome 59, Windows 10, and latest WCS server 2358

    rtsp-as-webrtc.jpg
  7. Max

    Max Administrator Staff Member

    Could you please share your RTSP URL and your reproducing steps?
    If RTSP URl is private, you can send it to logs@flashphoner.com
    We will check.

Share This Page