title: Icecast http connection latency over 30 seconds
body: <p>I'm running an icecast server (2.4.3) and experiencing a very long "time to first byte". It's strange because this does not seem to be occurring from players (like mplayer), but only when using HTML5 audio. It takes anywhere from 30 seconds to 120 seconds to start playing the audio.</p>
  
  <p>I'm thinking it's not a buffering issue because I don't seem to be getting ANY bytes back during this time. For instance, if I run a curl command with the verbose flag:</p>
  
  <pre><code>~ben ~: curl http://radio.example.com:8000/radio.mp3 -v
  *   Trying XX.XX.XX.XXX...
  * TCP_NODELAY set
  * Connected to radio.example.com (XX.XX.XX.XXX) port 8000 (#0)
  &gt; GET /radio.mp3 HTTP/1.1
  &gt; Host: radio.example.com:8000
  &gt; User-Agent: curl/7.51.0
  &gt; Accept: */*
  &gt;
  </code></pre>
  
  <p>It will sit like this for at minimum 28 seconds before I see any bytes coming in. Conversely, if I run mplayer:</p>
  
  <pre><code>~ben ~: mplayer http://radio.example.com:8000/radio.mp3
  MPlayer 1.3.0-4.2.1 (C) 2000-2016 MPlayer Team
  Can't init Apple Remote.
  
  Playing http://radio.example.com:8000/radio.mp3.
  Resolving radio.example.com for AF_INET6...
  
  Couldn't resolve name for AF_INET6: radio.example.com
  Resolving radio.example.com for AF_INET...
  Connecting to server radio.example.com[XX.XX.XX.XXX]: 8000...
  
  Cache size set to 320 KBytes
  Cache fill:  0.00% (0 bytes)
  ICY Info: StreamTitle='';
  Cache fill:  5.00% (16384 bytes)
  ICY Info: StreamTitle='';
  Cache fill: 10.00% (32768 bytes)
  ICY Info: StreamTitle='';
  Cache fill: 15.00% (49152 bytes)
  ICY Info: StreamTitle='';
  
  ICY Info: StreamTitle='';
  
  
  Audio only file format detected.
  ==========================================================================
  Requested audio codec family [mpg123] (afm=mpg123) not available.
  Enable it at compilation.
  Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
  libavcodec version 57.24.102 (internal)
  AUDIO: 44100 Hz, 2 ch, floatle, 128.0 kbit/4.54% (ratio: 16000-&gt;352800)
  Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
  ==========================================================================
  AO: [coreaudio] 44100Hz 2ch floatle (4 bytes per sample)
  Video: no video
  Starting playback...
  </code></pre>
  
  <p>It buffers and starts playing within a couple seconds.</p>
  
  <h2>Icecast config</h2>
  
  <p>Here are what I think are the relevant configs</p>
  
  <pre><code>&lt;icecast&gt;
      &lt;limits&gt;
          &lt;clients&gt;100&lt;/clients&gt;
          &lt;sources&gt;2&lt;/sources&gt;
          &lt;queue-size&gt;102400&lt;/queue-size&gt;
          &lt;client-timeout&gt;30&lt;/client-timeout&gt;
          &lt;header-timeout&gt;15&lt;/header-timeout&gt;
          &lt;source-timeout&gt;1&lt;/source-timeout&gt;
          &lt;burst-size&gt;943718&lt;/burst-size&gt;
          &lt;mp3-metadata-interval&gt;4096&lt;/mp3-metadata-interval&gt;
      &lt;/limits&gt;
  
  
      &lt;mount&gt;
          &lt;mount-name&gt;/radio.mp3&lt;/mount-name&gt;
          &lt;password&gt;*****************&lt;/password&gt;
  
          &lt;bitrate&gt;128&lt;/bitrate&gt;
          &lt;type&gt;audio/mpeg&lt;/type&gt;
          &lt;subtype&gt;mp3&lt;/subtype&gt;
          &lt;hidden&gt;0&lt;/hidden&gt;
          &lt;fallback-mount&gt;/whitenoise.mp3&lt;/fallback-mount&gt;
          &lt;fallback-override&gt;1&lt;/fallback-override&gt;
      &lt;/mount&gt;
  &lt;/icecast&gt;
  </code></pre>
  
  <h2>Attempts to fix</h2>
  
  <p>I've tried this on a few different versions including 2.3.3, 2.3.3-kh-11, 2.4.0-kh4. I've gotten this to work properly with a kh branch in the past but I was not able to get the fallback mounts to work with the kh branch. I might just give up and try to go down that rabbit hole instead. I've also tried fiddling with all the of the burst and buffer configs but this problem doesn't seem to be related to those.</p>