0

I'm getting the following error in the RTMP block of my nginx.conf when I attempt to run it in a dockerized setup.

[emerg] 1#1: host not found in url "api-servers/api/livevideostreams/startlivevideostream;

When Nginx attempts to read the one_publish and on_publish_done lines part of the rtmp block :

rtmp { server { listen 1935; on_publish http://api-servers/api/livevideostreams/startlivevideostream; on_publish_done http://api-servers/api/livevideostreams/stoplivevideostream; } } 

The upstream block is defined as

upstream api-servers { # Here we can specify multiple upstream servers of django api for load balancing. server 172.16.16.6:7575;# load balancing server 1 server 172.16.16.7:8585;# load balancing server 2 } 

The http code block which proxies the upstream server:

http { server{ listen 8080; location / { proxy_pass http://api-servers; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_buffering on; proxy_cache my_zone; add_header X-Proxy-Cache $upstream_cache_status; # WebSocket support (nginx 1.4) proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_redirect off; } } } 

Note : I'm Building a live streaming application using nginx rtmp module. I've attached relevant code only. The 2 upstream api servers are listening on 2 separate docker containers. the media server is a separate container as well where nginx.conf is configured.

I also tested the above nginx.conf without the rtmp block and I'm able to successfully hit the upstream blocks. Made 4 requests, 3 of them hit the 1st load balancing server and the 4th hit the 2nd load balancing server after checking the access logs. There is some issue with resolving the rtmp part of upstream servers.

Thank you in advance.

5
  • rtmp cannot use upstreams defined in http block. And there is no upstream directive in rtmp documentation. Commented Nov 21, 2024 at 18:26
  • Ok. So I can specify only one of the load balancing server address to use on_publish and on_publish_done. Thanks for your input Alexey. Commented Nov 21, 2024 at 18:35
  • I guess you could use on_publish http://localhost:8080/api/livevideostreams/startlivevideostream; since it will be proxied to one of two upstreams and thats what you want. Commented Nov 21, 2024 at 22:15
  • Or declare dedicated server block for this proxy. Commented Nov 21, 2024 at 22:16
  • Alexey. Just a clarification. The 2 upstream api servers are listening on 2 separate docker containers. the media server is a separate container as well where nginx.conf is configured. Commented Nov 22, 2024 at 4:05

1 Answer 1

0

rtmp module doesn't have upstream directive. But you could use http module for that.

For example:

http { server { listen 127.0.0.1:9999; # ^^^^ using random free port location / { proxy_pass http://api-service; } } # ... # other http servers # ... } rtmp { server { listen 1935; on_publish http://127.0.0.1:9999/api/livevideostreams/startlivevideostream; # using server declared above on_publish_done http://127.0.0.1:9999/api/livevideostreams/stoplivevideostream; } } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.