我在ejabberd中添加了一个名为mod_confirm_delivery
的自定义模块,该模块已成功编译并添加但当我发送消息时,我的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。我无法理解问题是什么,如何解决此错误。
答案 0 :(得分: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
hook的新签名:
user_send_packet(Packet, C2SState, From, To) -> Packet
如有疑问,您可以参考ejabberd文档中的官方挂钩列表:https://docs.ejabberd.im/developer/hooks/