Skip to content

[bug] streams are not playable when 'reuseport' is specified #144

@HeyJupiter

Description

@HeyJupiter

Hello, the module has worked fine for me for a long time. I planned to run Nginx in multi-processes mode to take advantage of high performance of it, so I deployed Nginx as you mention in Note and it worked fine. However, it was not load-balanced:
nginx-load
Then I hacked source files and found that the module might support reuseport, I tried to deploy it again and fortunately my testing OS supported it. But something weird happened, I got lots of errors as below:

2019/12/28 20:57:49 [error] 5997#0: *803 live: stream not found, client: ::ffff:127.0.0.1, server: [::]:1935
2019/12/28 20:57:49 [error] 5997#0: *804 live: stream not found, client: ::ffff:127.0.0.1, server: [::]:1935
2019/12/28 20:57:49 [error] 5997#0: *805 live: stream not found, client: ::ffff:127.0.0.1, server: [::]:1935
2019/12/28 20:57:49 [error] 5997#0: *806 live: stream not found, client: ::ffff:127.0.0.1, server: [::]:1935

If I omitted the option reuseport, it worked. If I added it, errors again appeared. Is it just the bug you have expected to fix? Please ignore it if it is.
It is beyond my ability to fix the bug, so no PR this time:(
Many thanks!

Expected behavior

Streams can be played when reuseport is specified.

Actual behavior

Lots of stream not found errors when reuseport is specified.

Steps to reproduce the behavior

1.Make sure you have an OS that supports reuseport option.
2.Specify option reuseport for the directive listen and turn on the directive rtmp_auto_push and run Nginx in multi-processes mode.
3.Push a stream to Nginx and then initiate many play requests to it.

My OS is CentOS 7.5 and my nginx.conf:

user www-data www-data;

worker_processes  auto;
worker_cpu_affinity auto;

error_log  logs/error.log error;

events {
    worker_connections  4096;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    keepalive_timeout  65;

    server {
        listen       80 reuseport;
        server_name  xxx;

        location / {
            root  /var/www;
            index index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location /live {
            flv_live on;

            chunked_transfer_encoding on;

            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
        }

        location /control {
            rtmp_control all;
        }

        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root /var/www/rtmp;
        }
    }
}

rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;

rtmp {
    out_queue   4096;
    out_cork    8;
    chunk_size  512;
    publish_time_fix on;
    idle_streams off;

    server {
        listen 1935 reuseport;

        application myapp {
            live on;
            gop_cache on;

            wait_video on;
            wait_key on;
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions