Search code examples
liquidsoap

Liquidsoap cannot write data to host: Broken pipe in write() error


My liquidsoap audio stream has just started to stop playing with this error message every few requests.

Error while sending data: could not write data to host: Broken pipe in write()!

It seems to fix itself pretty quickly and I can restart playing, but the interruption is annoying.

The liquidsoap script I'm using is pretty basic and pulls some songs from a database.

Here is the script.

def apply_metadata(m) =
  title = m["title"]
  artist = m["artist"]
  log("Now playing: #{title} by #{artist}")
end

def apply_track(m) =
  get_process_lines("curl http://localhost/api/v1/liquidsoap/playing")
  log("actually playing")
end

def get_request() =
  uri = list.hd(default="",get_process_lines("curl http://localhost/api/v1/liquidsoap/next"))
  request.create(uri)
end

def my_safe(s) =
  security = sine()
  fallback(track_sensitive=false,[s,security])
end

s = request.dynamic(id="s",timeout=60.0,get_request)
s = on_metadata(apply_metadata,s)
s = on_track(apply_track,s)
s = crossfade(s)
s = my_safe(s)

# We output the stream to an icecast
# server, in ogg/vorbis format.
output.icecast(
  %mp3(id3v2=true,bitrate=128,samplerate=44100),
  host = "localhost",
  port = 8000,
  mount = "ogr",
  s
)

Here is the liquidsoap log.

2018/09/15 17:23:04 [lang:3] Now playing: La Sirena by Banyan
2018/09/15 17:23:17 [lang:3] actually playing
2018/09/15 17:23:17 [ogr:3] Metadata update may have failed with error: 400, Bad Request (HTTP/1.0)
2018/09/15 17:23:17 [clock.wallclock_main:2] We must catchup 13.88 seconds!
2018/09/15 17:23:17 [ogr:2] Error while sending data: could not write data to host: Broken pipe in write()!
2018/09/15 17:23:17 [ogr:3] Closing connection...
2018/09/15 17:23:17 [ogr:3] Will try to reconnect in 3.00 seconds.
2018/09/15 17:23:18 [clock.wallclock_main:2] We must catchup 7.12 seconds (we've been late for 100 rounds)!
2018/09/15 17:23:21 [ogr:3] Connecting mount ogr for source@localhost...
2018/09/15 17:23:21 [ogr:3] Connection setup was successful.

I'm not sure why it has started doing this as it's been working perfectly for a long time previously and I've made no changes.

Any suggestions or help much appreciated as my understanding of liquidsoap is very basic.

Thanks.


Solution

  • In case anyone else comes across this error message in my case the problem was not with liquid soap itself, but that an API request was taking too long and it was causing the scheduling to fail.