freeswitch icon indicating copy to clipboard operation
freeswitch copied to clipboard

mod_erlang_event doesnt work with >= OTP25

Open macrocreation opened this issue 2 years ago • 2 comments

The current version of mod_event_erlang fails to work with erlang OTP25 and above. The distribution protocol changed from version 5 to version 6 . OTP 23 to OTP 24 were the only ones that supported backward versions. As of OTP 25 only version 6 is supported.

Freeswitch builds against OTP25 libraries fine but throws up errors on running any bind or other events as the version has changed.

ei_helpers.c needs to be updated as well as the makefiles to detect the version of OTP version being run if backward compatibility is required.

This is a PSA.

macrocreation avatar Jul 02 '23 19:07 macrocreation

Xadhoom made a fix for mod_kazoo. It's probably not too difficult to adopt the changes made in mod_kazoo into mod_erlang_event. Personally, I prefer mod_kazoo ;)

voughtdq avatar Aug 14 '23 02:08 voughtdq

I'm with @voughtdq there. I got into mod_erlang_event quite deeply while trying to update our app running in production since 2020 with FreeSWITCH 1.10.1 and Erlang 22, and hitting quite a few issues (details in #2808).

Unfortunately, even though mod_kazoo is newer, better thought out (from what I can tell so far), and more performant, but it has even less documentation available than mod_erlang_event (which is quite a feat) and it is not a drop-in replacement for mod_erlang_event.

toraritte avatar May 26 '25 13:05 toraritte

Hey @toraritte, I posted a gist which might help you figure out how to use mod_kazoo. It is written in Elixir, but if you look at the original mod_kazoo.erl you can get a feel for how to remove the kazoo-specific dependencies.

voughtdq avatar Jul 19 '25 09:07 voughtdq

@macrocreation is this still an issue? I just burned 10 hours here on:

Sending initial call event for 558b8468-1fb6-4893-ab78-abd9b87ab842 2025-07-26 20:43:09.022939 97.30% [ERR] mod_erlang_event.c:1075 listener exit: status=-1, erl_errno=0 errno=0 2025-07-26 20:43:09.022939 97.30% [DEBUG] mod_erlang_event.c:1144 Connection Closed

Running latest OTP

EP-PCOM avatar Jul 26 '25 20:07 EP-PCOM

@EP-PCOM (and others encountering this issue):
At the time of writing this (2025/07/26 2148 UTC), mod_erlang_event won't work with OTP versions higher than 22 (roughly). To quote section 1.2 and 1.3 from issue #2808 :

1.2 Potential root cause

This erlang/otp commit on Apr 27, 2020 fixed ei_send function by properly setting erl_errno to 0 on success instead of ignoring it.

mod_erlang_event.c's listener_main_loop only checks erl_errno for the expected "errors" (EAGAIN and ETIMEDOUT), because none of the ei functions used in the loop have ever re-set it - until the fix above. Now, when the HEARTBEAT event is sent, erl_error is re-set to 0 and the while loop exits.

1.3 Potential fix

Change

while ((status >= 0 || erl_errno == ETIMEDOUT || erl_errno == EAGAIN) && !prefs.done) {

to

while ((status >= 0 || erl_errno == ETIMEDOUT || erl_errno == EAGAIN || erl_errno == 0) && !prefs.done) {

toraritte avatar Jul 26 '25 21:07 toraritte