1

I have added a customized module named mod_confirm_delivery in ejabberd which has compiled and added successfully but when i am sending a message an error is coming in my ejabberd error log file, That is:

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}]}]}

I have ejabberd 16.02.26 and my module code is: mod_confirm_delivery.erl

This module is working fine with ejabberd 2.1.13 but i want to upgraded my ejabberd. I can't understand what is the problem and how can I resolve this error.

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
Hemant Sharma
  • 514
  • 6
  • 17

1 Answers1

1

undef error means the function or module is not found. The most likely error is that the mod_confirm_delivery.beam file is not in Erlang VM path.

You should try moving the compiled beam file with other ejabberd beam files or try setting the path used to launch Erlang to the directory where your mod_confirm_delivery.beam file is located. This is the -pa option of the Erlang VM.

If your code if in right place, other option is that the function is undefined. The hook tries to call mod_confirm_delivery:send_packet/4. Your code is wrong as it indeed does not defined send_packet/4 but only send_packet/3. You need to update your code to match new signature for user_send_packet hook:

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

In case of doubt, you can refer to official hook list in ejabberd documentation: https://docs.ejabberd.im/developer/hooks/

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
  • Hi Mickael, Thanks for reply. I have checked **/lib/ejabberd/ebin/** directory, here **mod_confirm_delivery.beam** is present with other beam files. Am i missing something or should i check another directory. – Hemant Sharma Mar 15 '16 at 12:26
  • I updated my answer for case where undef apply to the function. You need to update your code to match latest user_send_packet signature (see updated answer). – Mickaël Rémond Mar 15 '16 at 12:51
  • Hi mickael, i have changed the signature. Now mod_confirm_delivery is fine but i got another error in **ejabberd_sm.erl**, That is: – Hemant Sharma Mar 16 '16 at 10:52
  • [error] <0.2420.0>@ejabberd_sm:route:115 {function_clause,[{ejabberd_sm,do_route,[{jid,<<"test1">>,<<"localhost">>,<<"D-5">>,<<"test1">>,<<"localhost">>,<<"D-5">>},{jid,<<"test1">>,<<"localhost">>,<<>>,<<"test1">>,<<"localhost">>,<<>>},ok],[{file,"src/ejabberd_sm.erl"},{line,396}]}, – Hemant Sharma Mar 16 '16 at 10:55
  • {ejabberd_sm,route,3,[{file,"src/ejabberd_sm.erl"},{line,113}]},{ejabberd_local,route,3,[{file,"src/ejabberd_local.erl"},{line,112}]},{ejabberd_router,route,3,[{file,"src/ejabberd_router.erl"},{line,75}]},{ejabberd_c2s,check_privacy_route,5,[{file,"src/ejabberd_c2s.erl"},{line,2113}]},{ejabberd_c2s,session_established2,2,[{file,"src/ejabberd_c2s.erl"},{line,1271}]},{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}]}]} – Hemant Sharma Mar 16 '16 at 10:55
  • May you please tell me what is the solution for **function_clause** error – Hemant Sharma Mar 16 '16 at 10:57
  • @HemantSharma have you solved the problem at the end? If yes can you tell me how to modify the mod_confirm_delivery module please? – MattC Oct 11 '16 at 10:24