arut / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
13.35k stars 3.51k forks source link

"Stat" drops user count after some time. #159

Open jbvsmo opened 11 years ago

jbvsmo commented 11 years ago

I updated the module to latest version on master, but something happens after an user is connected on rtmp for too much time. This is what normally happens:

  1. The first user starts the player
  2. nginx-rtmp opens an URL to tell a program there's a new user for a certain stream
  3. The program opens a ffmpeg instance that loads data from some server, transcodes the video, and publishes in this same application
  4. The user watches the video and the counter on "stat" is 2 (one viewer + one publisher)

If there are new viewers, my program will not open new ffmpeg instances.

The problem is that, after some time, the counter on "stat" drops to zero! without disconnecting anything nor calling exec_play_done (but the original viewer keeps watching the video and ffmpeg keeps working).

The nginx-rtmp will not acknowledge that ffmpeg is still transmitting data and will not send the available streams to new users.

This is my application:

application rio {
    hls on;
    hls_path /tmp/hls;
    hls_fragment 15s;

    live on;
    exec_play /usr/bin/curl http://localhost:8000/$name/start;
    exec_play_done /usr/bin/curl http://localhost:8000/$name/stop;
}

I think this is not a problem with the "stat" part, but on the "rtmp" part.

arut commented 11 years ago

How many workers do you have? Stat does not work properly in multi-worker mode.

jbvsmo commented 11 years ago

Now I'm using 4 workers (I did this change at the same time as upgrading the nginx-rtmp). I had just 1 worker prior to this.

I'll see if going back to 1 user the count will stay right now.

But, why does the module do not send the available stream to new users even if ffmpeg is still transmitting?

jbvsmo commented 11 years ago

With only one worker, the module works fine. But can't it reliably stream videos using more workers?

misiek08 commented 11 years ago

I thought about multi workers stat. To make it the easiest way I think you can make separate stat file for each worker. So when now we setup http location with rtmp_stat all then we will use rtmp_stat all 1 where 1 is worker number.

shany0730 commented 10 years ago

i found the solution in http://nginx-rtmp.blogspot.ru/2013/06/multi-worker-statistics-and-control.html https://github.com/arut/nginx-rtmp-module/issues/258 thks