Common issues

Scripting issues

I can't update a variable !

The liquidsoap language is a functional language. Hence, you cannot do:

x = 0

def f () = 
  x = 1
end

f ()
print("x: #{x}")

This code will print "x: 0".

In functional languages, variables are not a reference to a value which can be updated. Instead, you redefine a new value. For instance, in the above code, you should do:

x = 0

def f () = 
  1
end

x = f ()
print("x: #{x}")

There can be cases where you really need to change the value of a variable without being able to redefine it. This is for instance the case when using callbacks such as on_metadata. In this case, you can use the string.ref operator:

# Get a string ref:
x = string.ref("initial value")
# The first argument of x is the getter function:
get_value = fst(x)
# The second is the setter function:
set_value = snd(x)

# New define a function
def f () = 
  set_value("updated value")
end

# Call function f
f ()

# Now print the result
print("current value: #{get_value ()}")

This code will print: "current value: updated value".

You can also use the string conversion functions, float_of_string and the like to obtain float, int and bool static references.

Troubleshooting

Liquidsoap does not start

Unbound symbol output.icecast.mp3 (or output.file.mp3, etc.)

It seems that your liquidsoap is not compiled with mp3 encoding support (liquidsoap uses liblame for that, which is non-free). Either re-compile liquidsoap, or use output.icecast.vorbis, or use output.icecast.lame if you have the lame binary available.

Liquidsoap does not run as expected

I see logs lines saying "We must catchup 3.59 seconds!" or "Too much latency! Resetting active sources."

Liquidsoap runs in realtime. If, for some reason, liquidsoap gets late, it will try to catchup the delay, which often results in a high temporary load on the system. If this delay has become too important, all active sources are reseted (see configuration key "root.max_latency").

A delay can be caused by a bug in liquidsoap, but also a task in the script that takes too much time to be processed, or even an external task, like a cron job.

It is recommended for a streaming server to run regular ntpdate jobs in order to maintain the local time in sync.

Liquidsoap crashes

Liquidsoap froze after I updated my server's local time

When running in realtime, liquidsoap uses the local time to check that it is not late. When setting this time to a new value, it creates a time gap. If this gap is small enough, liquidsoap can proceed as normal, but if it is too important, or even "impossible", like setting time back, then liquidsoap will fail.