arut / nginx-rtmp-module

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

nginx: [emerg] host not found in url #766

Open beardedbob opened 8 years ago

beardedbob commented 8 years ago

Hi All,

I'm using ubuntu 14.04 with nginx and the rtmp module to transcode a 1080p to 720p and send it to twitch. I have it accepting the 1080p but when I add the push command to the .conf of nginx I get nginx: [emerg] host not found in url "live-1hr.twitch.tv/". I've used the same push commands in windows via nginx without any issues and if I use an IP it starts nginx so I'm presuming its something dns related?

Has anyone had this issue?

Thanks

Bob

misiek08 commented 8 years ago

You need to add resolver 8.8.8.8; in your config. By the way check your DNS config on Ubuntu.

beardedbob commented 8 years ago

Hi,

thanks for replying, i've tried adding the nameserve 8.8.8.8 8.8.8.4.4 to the resov.conf but this still doesn't allow me to start ngnix with a domain url for the push key.

misiek08 commented 8 years ago

Can you show full nginx config?

beardedbob commented 8 years ago

Hi,

Yep see below

user nobody;

worker_processes 1;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;

events { worker_connections 1024; }

http { allow all; deny all;

access_log          logs/rtmp_access.log;
include             mime.types;
default_type        application/octet-stream;
sendfile            on;
keepalive_timeout   65;

server {
    listen      8081;
    server_name localhost;

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

    location /stat.xsl {
        # you can move stat.xsl to a different location
        root html;
    }

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

}

rtmp { server { listen 1935; chunk_size 4096;

        application live {
                live on;
                meta copy;
                exec ffmpeg -i rtmp://192.168.0.8/live -vcodec libx264 -#preset veryfast -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -#maxrate 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy #-f flv push rtmp://192.168.0.17/live1;

       }

        application live1 {
                live on;
                meta copy;

push rtmp://live-1hr.twitch.tv/live_*****; } } }

it complains that the push for live1 is the issue and its the url.

misiek08 commented 8 years ago

Try to add

resolver 8.8.8.8;

to rtmp block. It's nginx option too, not only resolv.conf :)

Propably server restart should help too, becuase it's clear - your nginx can't resolve DNS name.

beardedbob commented 8 years ago

thanks for your help so far, i've treid that and it returns the following

nginx: [emerg] "resolver" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:52

the code is as follows

user nobody;

worker_processes 1;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;

events { worker_connections 1024; }

http { allow all; deny all;

access_log          logs/rtmp_access.log;
include             mime.types;
default_type        application/octet-stream;
sendfile            on;
keepalive_timeout   65;

server {
    listen      8081;
    server_name localhost;

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

    location /stat.xsl {
        # you can move stat.xsl to a different location
        root html;
    }

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

}

rtmp { server { listen 1935; chunk_size 4096; resolver 8.8.8.8; application live { live on; meta copy; exec ffmpeg -i rtmp://192.168.0.8/live -vcodec libx264 -preset veryfast -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -maxrate 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy -f flv push rtmp://192.168.0.17/live1;

        }

        application live1 {
                live on;
                meta copy;

push rtmp://live-1hr.twitch.tv/live_*****; } } }

sergey-dryabzhinsky commented 8 years ago

Why do you need to push in back to nginx and push it again further? Just tell ffmpeg to push it directly to twitch.

sergey-dryabzhinsky commented 8 years ago

And nginx-rtmp not support resolver directive. So remove it from rtmp { } block.

beardedbob commented 8 years ago

I want use multiple push's to different rtmp servers in different resolutions / bitrates along with some using the record function, I've not not yet added them as I wanted to get the first working then scale it up.

I've removed the resolver directive but this was how it was originally and it still has the original issue.

sergey-dryabzhinsky commented 8 years ago

$ host live-1hr.twitch.tv Host live-1hr.twitch.tv not found: 3(NXDOMAIN)

There is no such host. Check you url.

beardedbob commented 8 years ago

Correct this was a typo when editing the config for here it's live-Lhr.twitch.tv I also ran it using Live-cdg.Twitch.TV and got the same response.

sergey-dryabzhinsky commented 8 years ago

Can you ever do ping Live-cdg.Twitch.TV from machine with nginx?

sergey-dryabzhinsky commented 8 years ago

And what version of nginx you are using?

viktor6 commented 8 years ago

Nginx and rtmp not start after reboot Here is my config

May 1 15:59:57 nginx[991]: nginx: [emerg] host not found in url "a.rtmp.youtube.com/live2/xxxxxxxxxxxxxxxxx" in /etc/nginx/nginx.conf:81 May 1 15:59:57 nginx[991]: nginx: configuration file /etc/nginx/nginx.conf test failed

`

user www-data; worker_processes auto;

error_log /var/log/nginx/rtmp_error.log debug;

error_log /var/log/nginx/rtmp_error.log; pid /run/nginx.pid;

events { worker_connections 1024;

multi_accept on;

}

http { allow all; deny all;

access_log /var/log/nginx/rtmp_access.log;

    include       mime.types;
    default_type  application/octet-stream;  
    sendfile on;
keepalive_timeout 65;

server { listen 80; server_name localhost;

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

    error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root /var/www/html;
    }

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

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

}

rtmp { server { listen 1935; chunk_size 8192;

#Restream
    application live {
                live on;
                meta copy;

                # Direct streaming:

        # GamingLive
                #push rtmp://broadcastEU.gaminglive.tv/push/sneaky4oe?secret=******************;

        # HitBox
                #push rtmp://live.hitbox.tv/push/sneaky4oe?key=************; #hitbox

        # Cybergame source
                #push rtmp://premium.cybergame.tv:1953/premium/sneaky4oe?key=*****************; #cybergame source

        # dailymotion (restream.io)
                #push rtmp://publish.dailymotion.com/publish-dm/*******?auth=****************************; #dailymotion

        # Twitch source 
              #  push rtmp://live-arn.justin.tv/app/live_xxxxxxxxxxxxx;

        # Twitch source 
                #push rtmp://live-arn.justin.tv/app/live_xxxxxxxxxxxxxx;
        # youtube source
                push rtmp://a.rtmp.youtube.com/live2/xxxxxxxxxxxxxxxxx;

  }
}

}`

unclemusclez commented 7 years ago

I have this same issue when trying to push to youtube. On boot/restart, nginx will not start automatically. After the computer has booted up, if I run sudo service nginx restart, it will start fine, just not before having to login and do it manually.

i only get the [emerg] host not found in url with the youtube link. Other services (twitch, beam, hitbox,) work fine on reboot. I was thinking about setting up some kind of redirect with the hosts file or nginx to test if it would automatically start as a workaround.

I compile rtmp module into EasyEngine's nginx-custom build. https://github.com/EasyEngine/nginx-build

ngoral commented 6 years ago

The same problem here.

neofutur commented 6 years ago

same problem here, on boot, the service will fail after each reboot, on :

jun 08 19:46:36 luz nginx[1109]: nginx: [emerg] host not found in url "a.rtmp.youtube.com/live2/secretrtmpkey

so, after every reboot of the machine I have to

service nginx restart

and then my rtmp nginx will work

a few remarks :

namgk commented 6 years ago

same here

Lax commented 6 years ago
2018/09/15 06:27:26 [error] 20113#0: connect() to [2607:f8b0:4006:30::c]:1935 failed (101: Network is unreachable)
2018/09/15 06:27:26 [error] 20113#0: *34 relay: push failed name='1234' app='' playpath='' url='a.rtmp.youtube.com/live2/vcf3-ke8r-exxy-083t', client: 110.38.212.147, server: 0.0.0.0:1935
2018/09/15 06:27:27 [alert] 16406#0: worker process 20113 exited on signal 11 (core dumped)
# host a.rtmp.youtube.com
a.rtmp.youtube.com is an alias for bartmp.l.google.com.
bartmp.l.google.com has address 74.125.0.9
bartmp.l.google.com has IPv6 address 2607:f8b0:4006:31::c
misiek08 commented 6 years ago

You can try specyfing resolver with ipv6=off flag.

sob., 15.09.2018, 08:45 użytkownik Liu Lantao notifications@github.com napisał:

2018/09/15 06:27:26 [error] 20113#0: connect() to [2607:f8b0:4006:30::c]:1935 failed (101: Network is unreachable) 2018/09/15 06:27:26 [error] 20113#0: *34 relay: push failed name='1234' app='' playpath='' url='a.rtmp.youtube.com/live2/vcf3-ke8r-exxy-083t', client: 110.38.212.147, server: 0.0.0.0:1935 2018/09/15 06:27:27 [alert] 16406#0: worker process 20113 exited on signal 11 (core dumped)

host a.rtmp.youtube.coma.rtmp.youtube.com is an alias for bartmp.l.google.com.bartmp.l.google.com has address 74.125.0.9bartmp.l.google.com has IPv6 address 2607:f8b0:4006:31::c

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/arut/nginx-rtmp-module/issues/766#issuecomment-421535965, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbp9ufuC5L4t196TJufKahIMvGZtZZqks5ubKH1gaJpZM4HfQH_ .

Lax commented 6 years ago

@misiek08 I saw you have suggested many times in this thread, but can you please give more information about how to set resolver in rtmp block?

As metioned in http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver, resolver can only be set in Context: http, server, location

# nginx -t
nginx: [emerg] "resolver" directive is not allowed here in /usr/local/nginx/conf/rtmp.conf:25
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
Marcello09 commented 5 years ago

I've also got the same problem here... any updates on how to fix this issue?

Marcello09 commented 5 years ago

Well... as a workaround to fix this issue upon reboot I've added Restart and a RestartSec directives to nginx.service so it can recover from this specific error. Tested on CentOS7 with Nginx 1.15.8 and RTMP module.

Here is my nginx.service file

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure
RestartSec=5s
PrivateTmp=true

[Install]
WantedBy=multi-user.target
Lax commented 5 years ago

I fixed it by adding a short delay once after a system reboot.

#/etc/systemd/system/nginx.service.d/override.conf 
[Service]
ExecStartPre=/bin/sleep 10
Restart=on-failure
RestartSec=5s
successtheman commented 3 years ago

I fixed it by adding a short delay once after a system reboot.

#/etc/systemd/system/nginx.service.d/override.conf 
[Service]
ExecStartPre=/bin/sleep 10
Restart=on-failure
RestartSec=5s

Although I am a bit late to the party, I can confirm that this seems to do the trick for me as well, thanks for this Lax. I didn't compile it from source, but used the default package for Ubuntu 18.04 and had this exact same issue with the stream URL where it would error out when starting nginx on boot but a manual restart would then work.

calmasacow commented 3 years ago

I fixed it by adding a short delay once after a system reboot.

#/etc/systemd/system/nginx.service.d/override.conf 
[Service]
ExecStartPre=/bin/sleep 10
Restart=on-failure
RestartSec=5s

can you elaborate on this? Where is this being added? "/etc/systemd/system/nginx.service.d/override.conf". ??? I don't have this file. I'm on a raspberry pi

Thank you in advance

Lax commented 3 years ago

can you elaborate on this? Where is this being added? "/etc/systemd/system/nginx.service.d/override.conf". ??? I don't have this file. I'm on a raspberry pi

Thank you in advance

@calmasacow Just create the file at that location, maybe you need create the folder first.

calmasacow commented 3 years ago

can you elaborate on this? Where is this being added? "/etc/systemd/system/nginx.service.d/override.conf". ??? I don't have this file. I'm on a raspberry pi Thank you in advance

@calmasacow Just create the file at that location, maybe you need create the folder first.

doesn't seem to work on raspberry pi 4 raspian buster.

successtheman commented 3 years ago

I'm not on RPI so that may be why it worked for me. I'm using nginx on a macbook pro from 2008 running ubuntu LTS I believe. Only good use for the machine lol. Also have an sql server on it too plus a twitch bot

successtheman commented 3 years ago

Believe I am running the open source phantombot

Pi-irate commented 3 years ago

I fixed it by adding a short delay once after a system reboot.

Worked for me, I've been scratching my head for hours trying to get this to work. Thank you.

doesn't seem to work on raspberry pi 4 raspian buster.

worked for me on pi 4 raspbian buster.

sudo systemctl edit nginx.service

creates the folder and file to put Lax's code in.