1

我添加了一个名为mod_confirm_deliveryejabberd 的自定义模块,该模块已成功编译和添加,但是当我发送消息时,我的 ejabberd 错误日志文件中出现错误,即:

2016-03-15 17:03:38.306 [error] <0.2653.0>@ejabberd_hooks:run_fold1:368 {undef,[{mod_confirm_delivery,send_packet,[{xmlel,<<"iq">>,[{<<"xml:lang">>,<<"en">>},{<<"type">>,<<"get">>},{<<"id">>,<<"aacfa">>}],[{xmlcdata,<<"\n">>},{xmlel,<<"query">>,[{<<"xmlns">>,<<"jabber:iq:roster">>}],[]},{xmlcdata,<<"\n">>}]},{state,{socket_state,gen_tcp,#Port<0.58993>,<0.2652.0>},ejabberd_socket,#Ref<0.0.1.25301>,false,<<"12664578908237388886">>,undefined,c2s,c2s_shaper,false,false,false,false,[verify_none,compression_none],true,{jid,<<"test1">>,<<"localhost">>,<<"D-5">>,<<"test1">>,<<"localhost">>,<<"D-5">>},<<"test1">>,<<"localhost">>,<<"D-5">>,{{1458,41617,630679},<0.2653.0>},{2,{{<<"test2">>,<<"localhost">>,<<>>},{{<<"test1">>,<<"localhost">>,<<>>},nil,nil},nil}},{2,{{<<"test2">>,<<"localhost">>,<<>>},{{<<"test1">>,<<"localhost">>,<<>>},nil,nil},nil}},{0,nil},undefined,undefined,{userlist,none,[],false},c2s,ejabberd_auth_internal,{{127,0,0,1},41928},[],active,[],inactive,undefined,undefined,1000,undefined,300,300,false,0,0,true,<<"en">>},{jid,<<"test1">>,<<"localhost">>,<<"D-5">>,<<"test1">>,<<"localhost">>,<<"D-5">>},{jid,<<"test1">>,<<"localhost">>,<<>>,<<"test1">>,<<"localhost">>,<<>>}],[]},{ejabberd_hooks,safe_apply,3,[{file,"src/ejabberd_hooks.erl"},{line,382}]},{ejabberd_hooks,run_fold1,4,[{file,"src/ejabberd_hooks.erl"},{line,365}]},{ejabberd_c2s,session_established2,2,[{file,"src/ejabberd_c2s.erl"},{line,1268}]},{p1_fsm,handle_msg,10,[{file,"src/p1_fsm.erl"},{line,582}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}

我有 ejabberd 16.02.26,我的模块代码是: mod_confirm_delivery.erl

这个模块在 ejabberd 2.1.13 上运行良好,但我想升级我的 ejabberd。我不明白是什么问题以及如何解决此错误。

4

1 回答 1

1

undef 错误表示未找到函数或模块。最可能的错误是mod_confirm_delivery.beam文件不在 Erlang VM 路径中。

您应该尝试将已编译的梁文件与其他 ejabberd 梁文件一起移动,或者尝试将用于启动 Erlang 的路径设置为您的mod_confirm_delivery.beam文件所在的目录。这是 Erlang VM 的 -pa 选项。

如果您的代码在正确的位置,则其他选项是该函数未定义。钩子试图调用mod_confirm_delivery:send_packet/4. 您的代码是错误的,因为它确实没有定义send_packet/4但只有send_packet/3. 您需要更新代码以匹配user_send_packet钩子的新签名:

user_send_packet(Packet, C2SState, From, To) -> Packet

如有疑问,可以参考 ejabberd 文档中的官方钩子列表:https ://docs.ejabberd.im/developer/hooks/

于 2016-03-15T12:17:05.623 回答