Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Proxy-forwarding to Icecast with Nginx

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
curtisdf



Joined: 23 Oct 2009
Posts: 5

PostPosted: Fri Oct 23, 2009 4:49 pm    Post subject: Proxy-forwarding to Icecast with Nginx Reply with quote

I run a web server that uses Nginx on Port 80 to proxy web traffic to an HTTP server running on a different port (8080). I want to run Icecast proxied via Port 80 as well, because that server only has 1 IP address. (Main reason for Icecast proxying is to accomodate corporate firewalls that only allow http:// traffic on Port 80.)

I currently have Icecast running on Port 8000 (with Icegenerator as the stream source), with Nginx configured to forward traffic from http://radio.my.tld to http://radio.my.tld:8000 (config file provided below.)

Listening with a client media player (VLC) works on http://radio.my.tld:8000/my-mountpoint.mp3. But when I listen to http://radio.my.tld/my-mountpoint.mp3, the connection initiates and audio starts to play, but the connection mysteriously stops after 2 or 3 seconds. I have been poking around troubleshooting for several hours, but to no avail. I thought it involved metadata that's being sent from Icegenerator, but I turned it off and still have the same problem.

Any ideas? Has anyone gotten Nginx to successfully forward-proxy to an Icecast server on the same machine?

My /etc/nginx/nginx.conf looks like this:

Code:

user nginx nginx;
worker_processes 8;
error_log /var/log/nginx/error_log;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
}

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

    log_format main '$host $remote_addr - $remote_user [$time_local] "$request" $status $bytes_sent "$http_referer" "$http_user_agent"';

    access_log /var/log/httpd/access_log main;

    sendfile on;
    keepalive_timeout 5;

    gzip on;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    open_log_file_cache max=1000 inactive=20s min_uses=2 valid=1m;

    server {
        listen 80;
        server_name radio.my.tld;

        location / {
            proxy_buffering           off;
            proxy_ignore_client_abort off;
            proxy_intercept_errors    on;
            proxy_next_upstream       error timeout invalid_header;
            proxy_redirect            off;
            proxy_set_header          X-Host $http_host;
            proxy_set_header          X-Forwarded-For $remote_addr;
            proxy_connect_timeout     60;
            proxy_send_timeout        21600;
            proxy_read_timeout        21600;

            proxy_pass http://radio.my.tld:8000;
        }
    }

    SEVERAL OTHER server {...} ENTRIES HERE
    (involving other virtual hosts proxying from port 80 to the HTTP server)
}


And my /etc/icecast/icecast.xml looks like this:

Code:

<icecast>
    <limits>
        <clients>100</clients>
        <sources>3</sources>
        <threadpool>5</threadpool>
        <queue-size>524288</queue-size>
        <client-timeout>30</client-timeout>
        <header-timeout>15</header-timeout>
        <source-timeout>10</source-timeout>
        <burst-size>65535</burst-size>
    </limits>

    <authentication>
        <source-password>my-source-password</source-password>
        <relay-password>my-relay-password</relay-password>
        <admin-user>my-admin-user</admin-user>
        <admin-password>my-admin-password</admin-password>
    </authentication>

    <hostname>radio.my.tld</hostname>

    <listen-socket>
        <port>8000</port>
    </listen-socket>

    <fileserve>1</fileserve>

    <server-id>my-custom-server-id</server-id>

    <paths>
        <basedir>/usr/share/icecast</basedir>
        <logdir>/var/log/icecast</logdir>
        <webroot>/usr/share/icecast/web</webroot>
        <adminroot>/usr/share/icecast/admin</adminroot>
        <pidfile>/var/run/icecast/icecast.pid</pidfile>
    </paths>

    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>
        <playlistlog>playlist.log</playlistlog>
        <loglevel>4</loglevel>
    </logging>

    <security>
        <chroot>0</chroot>
        <changeowner>
            <user>icecast</user>
            <group>icecast</group>
        </changeowner>
    </security>
</icecast>



Thanks,
Curtis
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Fri Oct 23, 2009 7:02 pm    Post subject: Reply with quote

Your post says nothing about the listener connections as reported in the logs. Were they dropped for being slow or not?

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
curtisdf



Joined: 23 Oct 2009
Posts: 5

PostPosted: Fri Oct 23, 2009 7:32 pm    Post subject: Log entries Reply with quote

Sorry about omitting that. Here's info from the logs:

I have Icecast's log level set to Debug. Every 5 seconds, two entries like the following show up in /var/log/icecast/error.log
Code:
[2009-10-23  12:21:15] DBUG stats/modify_node_event update node total_bytes_read (74402687)
[2009-10-23  12:21:15] DBUG stats/modify_node_event update node total_bytes_sent (2455069)


When I connect via VLC to http://radio.my.tld:8000/my-mountpoint.mp3, the following entries appear in the same logfile:

Code:
[2009-10-23  12:27:32] DBUG auth/add_listener_to_source max on /my-mountpoint.mp3 is -1 (cur 0)
[2009-10-23  12:27:32] DBUG auth/add_listener_to_source Added client to /my-mountpoint.mp3
[2009-10-23  12:27:32] DBUG auth/add_authenticated_listener client authenticated, passed to source
[2009-10-23  12:27:32] DBUG stats/modify_node_event update node clients (2)
[2009-10-23  12:27:32] DBUG stats/modify_node_event update node connections (16)
[2009-10-23  12:27:32] DBUG stats/modify_node_event update node client_connections (12)
[2009-10-23  12:27:32] DBUG source/source_main Client added
[2009-10-23  12:27:32] INFO source/source_main listener count on /my-mountpoint.mp3 now 1
[2009-10-23  12:27:32] DBUG format/format_check_http_buffer processing pending client headers
[2009-10-23  12:27:32] DBUG stats/modify_node_event update node listeners (1)
[2009-10-23  12:27:32] DBUG stats/modify_node_event update node listeners (1)
[2009-10-23  12:27:32] DBUG stats/modify_node_event update node listener_connections (12)


But when I connect to http://radio.my.tld/my-mountpoint.mp3, the following lines show up instead:

Code:
[2009-10-23  12:24:40] DBUG auth/add_listener_to_source max on /my-mountpoint.mp3 is -1 (cur 0)
[2009-10-23  12:24:40] DBUG auth/add_listener_to_source Added client to /my-mountpoint.mp3
[2009-10-23  12:24:40] DBUG auth/add_authenticated_listener client authenticated, passed to source
[2009-10-23  12:24:40] DBUG source/source_main Client added
[2009-10-23  12:24:40] INFO source/source_main listener count on /my-mountpoint.mp3 now 1
[2009-10-23  12:24:40] DBUG stats/modify_node_event update node clients (2)
[2009-10-23  12:24:40] DBUG stats/modify_node_event update node connections (15)
[2009-10-23  12:24:40] DBUG stats/modify_node_event update node client_connections (11)
[2009-10-23  12:24:40] DBUG stats/modify_node_event update node listeners (1)
[2009-10-23  12:24:40] DBUG format/format_check_http_buffer processing pending client headers
[2009-10-23  12:24:40] DBUG stats/modify_node_event update node listeners (1)
[2009-10-23  12:24:40] DBUG stats/modify_node_event update node listener_connections (11)
[2009-10-23  12:24:44] DBUG client/client_send_bytes Client connection died
[2009-10-23  12:24:44] DBUG source/source_main Client removed
[2009-10-23  12:24:44] INFO source/source_main listener count on /my-mountpoint.mp3 now 0
[2009-10-23  12:24:45] DBUG stats/modify_node_event update node clients (1)
[2009-10-23  12:24:45] DBUG stats/modify_node_event update node listeners (0)
[2009-10-23  12:24:45] DBUG stats/modify_node_event update node listeners (0)


Thanks for being willing to take a look. Smile

-Curtis
Back to top
View user's profile Send private message
curtisdf



Joined: 23 Oct 2009
Posts: 5

PostPosted: Fri Oct 23, 2009 7:35 pm    Post subject: Log files Reply with quote

To answer your question, I'm not sure if the client is being slow or not. Those log lines are a bit difficult for me to decipher. But it clearly says, "Client connection died" about 13 lines down. That's the first sign of trouble that I gather from it.
Back to top
View user's profile Send private message
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Fri Oct 23, 2009 7:53 pm    Post subject: Reply with quote

That means the client connection was terminated (which will be the link to the proxy server) after about 4 seconds but not by icecast. The access log should show how much data was sent to vlc.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
curtisdf



Joined: 23 Oct 2009
Posts: 5

PostPosted: Fri Oct 23, 2009 8:44 pm    Post subject: client closed Reply with quote

Okay, thanks for the input. I see that now.

Anyone have any experience with Icecast proxied via Nginx??? Could Icegenerator be causing this? (I plan to try with a different stream source as soon as I get the chance.)

I've combed through the Nginx documentation, comparing the directives there to my config settings, and I don't see any timeouts or other limits that might be causing the problem. But it's very possible I am overlooking something here.

I turned Nginx's error logging up to Debug level. When the client connection closes, Nginx's error_log shows the following:

Code:
2009/10/23 13:34:00 [info] 19978#0: *960561 client closed prematurely connection, so upstream connection is closed too (104: Connection reset by peer) while reading upstream, client: my.client.ip.addr, server: radio.my.tld, request: "GET /my-mountpoint.mp3 HTTP/1.1", upstream: "http://my.server.ip.addr:8000/my-mountpoint.mp3", host: "radio.my.tld"


I looked at the access logs too. The amount of data transferred each time varies a lot but stays between 8200 and 8900 bytes.
Back to top
View user's profile Send private message
curtisdf



Joined: 23 Oct 2009
Posts: 5

PostPosted: Thu Nov 12, 2009 4:13 am    Post subject: It's not an Icecast or Nginx problem Reply with quote

Well, it turns out not to be an Icecast or Nginx problem after all.

I tried it with Muse instead of Icegenerator, as well as mucking around with Nginx timeouts and proxy settings. Always the same problem.

Then it dawned on me that I had been trying it only with VLC as the client media player. So I tried with Windows Media Player instead. Lo and behold, it worked! It even worked when I put Icecast back to using Icegenerator instead of Muse, and with periodic metadata updates.

So it's a VLC problem. And an ongoing one, it appears. I upgraded my Win32 client box to the latest stable VLC (0.9.4) and on my Gentoo Linux/x86 box (0.9.10) and still the same problem with each.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber