sergey-dryabzhinsky / nginx-rtmp-module

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

Sending back a 403 HTTP code on_publish doesn't work #189

Open alexismartin opened 7 years ago

alexismartin commented 7 years ago

We're using on_publish in order to authentify our user and sending back a 403 Forbidden HTTP code when the auth failed.

But doing so makes OBS crash with the following log:

23:01:55.728: [rtmp stream: 'simple_stream'] Connecting to RTMP URL rtmp://eu.condorleague.tv/yjalexis... 23:01:56.640: rtmp server requested close 23:01:56.640: authenticating publisher 23:01:57.432: rtmp server requested close 23:01:57.432: authenticating publisher 23:01:58.218: rtmp server requested close 23:01:58.218: authenticating publisher 23:01:58.902: rtmp server requested close 23:01:58.902: authenticating publisher 23:01:59.668: rtmp server requested close 23:01:59.669: authenticating publisher 23:02:00.374: rtmp server requested close 23:02:00.375: authenticating publisher 23:02:01.165: rtmp server requested close 23:02:01.165: authenticating publisher 23:02:01.958: rtmp server requested close

As a workaround we switched to sending a 500 HTTP code back, which makes OBS throw the regular "Can't access this stream key" error and serves our purpose, but you might want to look into it. I also realized, the behavior when sending back 4xx codes isn't detailed in the docs https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/wiki/Directives#on_play (from reading it 4xx and 5xx should work the same).

chriswiggins commented 7 years ago

@alexismartin can you please provide your config? I'm using 403 for on_play and it is working fine, so interested to see what could be causing it to fail for on_publish because essentially its the same notification path

alexismartin commented 7 years ago

So we have an ingest server with the following conf:

rtmp {
    server {
        listen 1935;
        chunk_size 8192;

        application yjalexis {
            live on;
            idle_streams off;
            interleave on;
            deny play all;
            on_publish http://rtmp.condorleague.tv/authorise.php;
            push rtmp://rtmp.condorleague.tv/yjalexis/live;
        }
    }
}

Which then pushes to another server with this conf:

rtmp {
    server {
        listen 1935;
        chunk_size 8192;

        application yjalexis {
            live on;
            idle_streams off;
            interleave on;
        }
    }
}