arut / nginx-rtmp-module

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

Multiple workers with live + auto_push + exec_pull not working? #849

Open nickygerritsen opened 8 years ago

nickygerritsen commented 8 years ago

So we have (roughly) the following config:

worker_processes 4;
rtmp_auto_push on;

/* Other config for HTTP */

rtmp {
        server {
                listen x.y.z.u:1935;

                application rtmplive {
                        record off;
                        live on;
                        exec_pull /usr/bin/media_rtmp_wrapper "$name" "$args";
                        exec_kill_signal term;

                        on_play http://myhost.com/rtmponplay/;

                        # Logging
                        access_log /var/log/rtmp.log combined;

                        # Allow playing from everywhere, but publishing only from our local IP
                        allow play all;
                        allow publish x.y.z.u;
                        deny publish all;
                }
        }
}

The rtmp wrapper starts an ffmpeg which streams a livestream from another source to the RTMP URL.

If I have worker_processes 4 (or anything > 1), I can randomly not get the stream to play. Using rtmpdump it then hangs on receiving data.

If I try some more times, it does work.

When I only have 1 worker process, everything always works.

Auto push is enabled, but I do seem to be getting errors in my debug log:

2016/07/01 15:12:50 [debug] 26950#0: *411 auto_push: reconnect
2016/07/01 15:12:50 [debug] 26950#0: *411 auto_push: connect slot=0 pid=26949 socket='unix:/tmp/nginx-rtmp.0' name='account=zr5gPuXJQ9kS.livestream=3osAsaVZf8q2'
2016/07/01 15:12:50 [debug] 26950#0: *411 auto_push: connect slot=2 pid=26951 socket='unix:/tmp/nginx-rtmp.2' name='account=zr5gPuXJQ9kS.livestream=3osAsaVZf8q2'
2016/07/01 15:12:50 [debug] 26950#0: *411 auto_push: connect slot=3 pid=26952 socket='unix:/tmp/nginx-rtmp.3' name='account=zr5gPuXJQ9kS.livestream=3osAsaVZf8q2'
2016/07/01 15:12:50 [debug] 26950#0: *411 auto_push: stat() failed: slot=4 pid=26953 socket='unix:/tmp/nginx-rtmp.4'url='' name='account=zr5gPuXJQ9kS.livestream=3osAsaVZf8q2'
2016/07/01 15:12:50 [debug] 26950#0: *411 auto_push: stat() failed: slot=5 pid=26954 socket='unix:/tmp/nginx-rtmp.5'url='' name='account=zr5gPuXJQ9kS.livestream=3osAsaVZf8q2'
2016/07/01 15:12:50 [debug] 26950#0: *411 auto_push: pushed=3 total=4 failed=0
2016/07/01 15:12:51 [debug] 26950#0: *414 auto_push: disconnect slot=3 app='' name='account=zr5gPuXJQ9kS.livestream=3osAsaVZf8q2'

Am I correct in thinking that it uses the wrong slots? I.e. it disconnects from slot 3, but pushes to slot 0, 2 and 3. What happened to slot 1?

nickygerritsen commented 8 years ago

Or maybe because app is empty?

xxxman2008 commented 7 years ago

multi-worker with auto-push is not stable, it's a well-know issue. And Author always tell us "DO NOT USE IT IN PRODUCTION".

darktar commented 7 years ago

i have the same trouble without the "auto-push", only live and hls on;. if i increase the workers upper than 1, the stream don't work. (i can push, but i can't watch). My computer is dual-core, and i would like use 2 workers to increase the fps.

misiek08 commented 7 years ago

Worker number has nothing to do with fps here. Nginx will handle traffic on one core and I think you will first hit bandwidth limit. Encoder should use multiple cores, but server don't have to.

shoujs commented 7 years ago

I am with @darktar The stream is not stable after I increase worker number to 2 from 1. I use ffmpeg to record the stream. But the process will hang there after recoding a few minutes.

ghost commented 7 years ago

hey can any one explain me what is worker_processes and worker_connections ?