I've just installed ejabberd from the sources (18.04) with MySQL support and changed the configuration file respectively. Basically everything works: ejabberd starts, I can register users, users can connect and send messages. I also see all users in the database so I assume the setup is so far correct.
Now I want to use the mod mod_mam
to archive all messages. For this I added to the ejabberd.yaml
file the following lines:
modules:
...
mod_mam:
db_type: sql
default: always
...
However, when I sent an offline message, I get the following error -- actually two similar errors for two functions using both the offline message hook:
[error] <0.541.0>@ejabberd_hooks:safe_apply:383 Hook offline_message_hook crashed when running mod_mam:offline_message/1:
** Reason = {error,function_clause,[{mod_mam,offline_message,[{file,"src/mod_mam.erl"},{line,366}],[ok]},{ejabberd_hooks,safe_apply,[{file,"src/ejabberd_hooks.erl"},{line,380}],4},{ejabberd_hooks,run_fold1,[{file,"src/ejabberd_hooks.erl"},{line,364}],4},{ejabberd_sm,route,[{file,"src/ejabberd_sm.erl"},{line,143}],1},{ejabberd_local,route,[{file,"src/ejabberd_local.erl"},{line,73}],1},{ejabberd_router,do_route,[{file,"src/ejabberd_router.erl"},{line,368}],1},{ejabberd_router,route,[{file,"src/ejabberd_router.erl"},{line,93}],1},{ejabberd_c2s,check_privacy_then_route,[{file,"src/ejabberd_c2s.erl"},{line,823}],2}]}
With an older installation (17.01) everything worked fine. But I don't know if additional MySQL tables are required. When I look into my current database, I actually all messages (including offline message) get stored in table archive
.
Do you use only the modules included in ejabberd, or did you install any of the contributed, or other custom modules?
Notice that offline_message_hook changed in 17.03 from "run" (without accumulator) to "run_fold" (with accumulator), which means that the result of a function call is passed to the next one, until all finish or one stops the hook.
See commit: https://github.com/processone/ejabberd/commit/e564f9ae31d2c5345be4eed66e70037ba8145dc1 and hook docs: https://docs.ejabberd.im/developer/guide/#hooks