Create a receive with a large timeout

receive do
      {event} ->
        IO.puts "event"
    after
      duration ->
        IO.puts "duration or timeout"
    end

i have a spawn process which is implemented like that. duration can be equal to 31536000000 ms which represents a year in ms. It works well for a day, a week, a month but not more. How can i get this thing work? the error I receive is

[error] Process #PID<0.295.0> raised an exception
** (ErlangError) erlang error: :timeout_value

Thank you for the help

1 Like

If you check in the Erlang documentation in the reference manual on the receive expression, http://erlang.org/doc/reference_manual/expressions.html#id80928, it explicitly says "ExprT is to evaluate to an integer. The highest allowed value is 16#FFFFFFFF, that is, the value must fit in 32 bits." and that ExprT is in milliseconds. This means that if you want a longer time then you will have to implement it in a sequence or loop of receive.

2 Likes