Module to handle custom iq stanzas does not work with ejabberd-18.09
I am trying to move to ejabberd-18.09 from ejabberd-17.03. I have this module so that I can send custom iq stanzas to ejabberd.
-module(mod_test_custom).
%% ====================================================================
%% API functions
%% ====================================================================
-export([start/2, stop/1, process_local_iq/3,depends/2,mod_opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
%% ====================================================================
%% Internal functions
%% ====================================================================
-define(NS_IQ_CUSTOM, <<"ns:custom">>).
start(Host, Opts) ->
IQDisc = gen_mod:get_opt(iqdisc, Opts, fun gen_iq_handler:check_type/1,
one_queue),
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM, ?MODULE, process_local_iq, IQDisc),
xmpp:register_codec(mod_custom),
?INFO_MSG("Inside mod_test_custom”,),
ok.
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM),
xmpp:unregister_codec(mod_custom),
ok.
depends(_Host, _Opts)->[{?MODULE,soft}].
mod_opt_type(_Option)->
.
process_local_iq(From,To,{iq, ID, get, NS, Language, SubElement} = IQ)->
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[IQ]),
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[From]),
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[To]),
{ _,ID , Type, Feature, Lang, {_,_,_,Sub_els} } = IQ,
Type,Lang,ID,Feature,
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[Sub_els]),
Sum = 2+2,
FoundSubEls = list_to_binary(integer_to_list(Sum)),
SubElement,
{iq, ID, result, NS, Language,[{xmlel,<<"query">>,[{<<"xmlns">>,<<"ns:custom">>}],[{xmlel,<<"response">>,[{<<"op">>,<<"sum">>},{<<"val">>,FoundSubEls}],}]}]}.
This module works fine with ejabberd-17.03 . But when I use it with ejabberd-18.09 I get the following error:
[info] (tcp|<0.523.0>) Received XML on stream = <<"<iq to='example.com' id='tZU4h-20' type='get'><query xmlns='ns:custom'><abc op='sum'></abc></query></iq><r xmlns='urn:xmpp:sm:3'/>">>
[debug] route:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
[debug] local route:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
[error] failed to process iq:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
Reason = {error,{undef,[{mod_test_custom,process_local_iq,[{iq,<<"tZU4h-20">>,get,<<"en">>,{jid,<<"caLmPSeeWQo">>,<<"example.com">>,<<"Smack">>,<<"caLmPSeeWQo">>,<<"example.com">>,<<"Smack">>},{jid,<<>>,<<"example.com">>,<<>>,<<>>,<<"example.com">>,<<>>},[{response,<<>>,<<>>}],#{ip => {}}}],},{gen_iq_handler,process_iq,3,[{file,"src/gen_iq_handler.erl"},{line,132}]},{gen_iq_handler,process_iq,4,[{file,"src/gen_iq_handler.erl"},{line,111}]},{ejabberd_local,route,1,[{file,"src/ejabberd_local.erl"},{line,72}]},{ejabberd_router,do_route,1,[{file,"src/ejabberd_router.erl"},{line,368}]},{ejabberd_router,route,1,[{file,"src/ejabberd_router.erl"},{line,92}]},{ejabberd_c2s,check_privacy_then_route,2,[{file,"src/ejabberd_c2s.erl"},{line,826}]},{xmpp_stream_in,process_authenticated_packet,2,[{file,"src/xmpp_stream_in.erl"},{line,637}]}]}}
[debug] route:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] local route:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] processing packet to full JID:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] sending to process <0.523.0>:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] Won't add stanza for caLmPSeeWQo@example.com/Smack to CSI queue
[info] (tcp|<0.523.0>) Send XML on stream = <<"<a h='5' xmlns='urn:xmpp:sm:3'/>">>
[debug] Flushing packets of @example.com from CSI queue of caLmPSeeWQo@example.com/Smack
[info] (tcp|<0.523.0>) Send XML on stream = <<"<iq xml:lang='en' to='caLmPSeeWQo@example.com/Smack' from='example.com' type='error' id='tZU4h-20'><query xmlns='ns:custom'><abc op='sum'/></query><error code='500' type='wait'><internal-server-error xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Module failed to handle the query</text></error></iq>">>
[info] (tcp|<0.523.0>) Send XML on stream = <<"<r xmlns='urn:xmpp:sm:3'/>">>
[debug] caLmPSeeWQo@example.com/Smack acknowledged 7 of 7 stanzas
[info] (tcp|<0.523.0>) Received XML on stream = <<"<a xmlns='urn:xmpp:sm:3' h='7'/>">>
I have followed these steps to register a custom iq https://github.com/processone/xmpp/issues/9 but still no luck.This is the element which I added in my xmpp/specs/xmpp_codec.spec file
-xml(response,
#elem{name = <<"query">>,
xmlns = <<"ns:custom">>,
module = mod_custom,
result = {response, '$op','$val'},
attrs = [#attr{name = <<"op">>},
#attr{name = <<"val">>}]}).
Am I missing something or is there any change in the way it should be done in ejabberd-18.09?
erlang xmpp ejabberd ejabberd-module ejabberd-hooks
|
show 1 more comment
I am trying to move to ejabberd-18.09 from ejabberd-17.03. I have this module so that I can send custom iq stanzas to ejabberd.
-module(mod_test_custom).
%% ====================================================================
%% API functions
%% ====================================================================
-export([start/2, stop/1, process_local_iq/3,depends/2,mod_opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
%% ====================================================================
%% Internal functions
%% ====================================================================
-define(NS_IQ_CUSTOM, <<"ns:custom">>).
start(Host, Opts) ->
IQDisc = gen_mod:get_opt(iqdisc, Opts, fun gen_iq_handler:check_type/1,
one_queue),
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM, ?MODULE, process_local_iq, IQDisc),
xmpp:register_codec(mod_custom),
?INFO_MSG("Inside mod_test_custom”,),
ok.
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM),
xmpp:unregister_codec(mod_custom),
ok.
depends(_Host, _Opts)->[{?MODULE,soft}].
mod_opt_type(_Option)->
.
process_local_iq(From,To,{iq, ID, get, NS, Language, SubElement} = IQ)->
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[IQ]),
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[From]),
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[To]),
{ _,ID , Type, Feature, Lang, {_,_,_,Sub_els} } = IQ,
Type,Lang,ID,Feature,
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[Sub_els]),
Sum = 2+2,
FoundSubEls = list_to_binary(integer_to_list(Sum)),
SubElement,
{iq, ID, result, NS, Language,[{xmlel,<<"query">>,[{<<"xmlns">>,<<"ns:custom">>}],[{xmlel,<<"response">>,[{<<"op">>,<<"sum">>},{<<"val">>,FoundSubEls}],}]}]}.
This module works fine with ejabberd-17.03 . But when I use it with ejabberd-18.09 I get the following error:
[info] (tcp|<0.523.0>) Received XML on stream = <<"<iq to='example.com' id='tZU4h-20' type='get'><query xmlns='ns:custom'><abc op='sum'></abc></query></iq><r xmlns='urn:xmpp:sm:3'/>">>
[debug] route:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
[debug] local route:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
[error] failed to process iq:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
Reason = {error,{undef,[{mod_test_custom,process_local_iq,[{iq,<<"tZU4h-20">>,get,<<"en">>,{jid,<<"caLmPSeeWQo">>,<<"example.com">>,<<"Smack">>,<<"caLmPSeeWQo">>,<<"example.com">>,<<"Smack">>},{jid,<<>>,<<"example.com">>,<<>>,<<>>,<<"example.com">>,<<>>},[{response,<<>>,<<>>}],#{ip => {}}}],},{gen_iq_handler,process_iq,3,[{file,"src/gen_iq_handler.erl"},{line,132}]},{gen_iq_handler,process_iq,4,[{file,"src/gen_iq_handler.erl"},{line,111}]},{ejabberd_local,route,1,[{file,"src/ejabberd_local.erl"},{line,72}]},{ejabberd_router,do_route,1,[{file,"src/ejabberd_router.erl"},{line,368}]},{ejabberd_router,route,1,[{file,"src/ejabberd_router.erl"},{line,92}]},{ejabberd_c2s,check_privacy_then_route,2,[{file,"src/ejabberd_c2s.erl"},{line,826}]},{xmpp_stream_in,process_authenticated_packet,2,[{file,"src/xmpp_stream_in.erl"},{line,637}]}]}}
[debug] route:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] local route:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] processing packet to full JID:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] sending to process <0.523.0>:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] Won't add stanza for caLmPSeeWQo@example.com/Smack to CSI queue
[info] (tcp|<0.523.0>) Send XML on stream = <<"<a h='5' xmlns='urn:xmpp:sm:3'/>">>
[debug] Flushing packets of @example.com from CSI queue of caLmPSeeWQo@example.com/Smack
[info] (tcp|<0.523.0>) Send XML on stream = <<"<iq xml:lang='en' to='caLmPSeeWQo@example.com/Smack' from='example.com' type='error' id='tZU4h-20'><query xmlns='ns:custom'><abc op='sum'/></query><error code='500' type='wait'><internal-server-error xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Module failed to handle the query</text></error></iq>">>
[info] (tcp|<0.523.0>) Send XML on stream = <<"<r xmlns='urn:xmpp:sm:3'/>">>
[debug] caLmPSeeWQo@example.com/Smack acknowledged 7 of 7 stanzas
[info] (tcp|<0.523.0>) Received XML on stream = <<"<a xmlns='urn:xmpp:sm:3' h='7'/>">>
I have followed these steps to register a custom iq https://github.com/processone/xmpp/issues/9 but still no luck.This is the element which I added in my xmpp/specs/xmpp_codec.spec file
-xml(response,
#elem{name = <<"query">>,
xmlns = <<"ns:custom">>,
module = mod_custom,
result = {response, '$op','$val'},
attrs = [#attr{name = <<"op">>},
#attr{name = <<"val">>}]}).
Am I missing something or is there any change in the way it should be done in ejabberd-18.09?
erlang xmpp ejabberd ejabberd-module ejabberd-hooks
The relevant part of the error:undef,[{mod_test_custom,process_local_iq
. That is, the functionmod_test_custom:process_local_iq
is undefined, most likely because themod_test_custom
module cannot be loaded. Where is the filemod_test_custom.beam
located?
– legoscia
Nov 22 '18 at 9:58
1
It is placed with the other .beam files of ejabberd i.e inside usr/local/lib/ejabberd-18.09/ebin folder. plus I have double checked it that it's entry is made in the modules section of ejabberd.yml
– abhishek ranjan
Nov 22 '18 at 10:02
That's strange, I would expect the module to be loaded automatically in that case...
– legoscia
Nov 22 '18 at 10:04
yes exactly, this is where it confuses me.
– abhishek ranjan
Nov 22 '18 at 10:06
1
Ah, you're right! I misread the error message. The problem is that ejabberd callsmod_test_custom:process_local_iq
with one argument, but your function expects three arguments. Looks like it gets called with an#iq{}
record, but not sure where that is defined...
– legoscia
Nov 23 '18 at 9:25
|
show 1 more comment
I am trying to move to ejabberd-18.09 from ejabberd-17.03. I have this module so that I can send custom iq stanzas to ejabberd.
-module(mod_test_custom).
%% ====================================================================
%% API functions
%% ====================================================================
-export([start/2, stop/1, process_local_iq/3,depends/2,mod_opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
%% ====================================================================
%% Internal functions
%% ====================================================================
-define(NS_IQ_CUSTOM, <<"ns:custom">>).
start(Host, Opts) ->
IQDisc = gen_mod:get_opt(iqdisc, Opts, fun gen_iq_handler:check_type/1,
one_queue),
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM, ?MODULE, process_local_iq, IQDisc),
xmpp:register_codec(mod_custom),
?INFO_MSG("Inside mod_test_custom”,),
ok.
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM),
xmpp:unregister_codec(mod_custom),
ok.
depends(_Host, _Opts)->[{?MODULE,soft}].
mod_opt_type(_Option)->
.
process_local_iq(From,To,{iq, ID, get, NS, Language, SubElement} = IQ)->
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[IQ]),
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[From]),
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[To]),
{ _,ID , Type, Feature, Lang, {_,_,_,Sub_els} } = IQ,
Type,Lang,ID,Feature,
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[Sub_els]),
Sum = 2+2,
FoundSubEls = list_to_binary(integer_to_list(Sum)),
SubElement,
{iq, ID, result, NS, Language,[{xmlel,<<"query">>,[{<<"xmlns">>,<<"ns:custom">>}],[{xmlel,<<"response">>,[{<<"op">>,<<"sum">>},{<<"val">>,FoundSubEls}],}]}]}.
This module works fine with ejabberd-17.03 . But when I use it with ejabberd-18.09 I get the following error:
[info] (tcp|<0.523.0>) Received XML on stream = <<"<iq to='example.com' id='tZU4h-20' type='get'><query xmlns='ns:custom'><abc op='sum'></abc></query></iq><r xmlns='urn:xmpp:sm:3'/>">>
[debug] route:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
[debug] local route:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
[error] failed to process iq:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
Reason = {error,{undef,[{mod_test_custom,process_local_iq,[{iq,<<"tZU4h-20">>,get,<<"en">>,{jid,<<"caLmPSeeWQo">>,<<"example.com">>,<<"Smack">>,<<"caLmPSeeWQo">>,<<"example.com">>,<<"Smack">>},{jid,<<>>,<<"example.com">>,<<>>,<<>>,<<"example.com">>,<<>>},[{response,<<>>,<<>>}],#{ip => {}}}],},{gen_iq_handler,process_iq,3,[{file,"src/gen_iq_handler.erl"},{line,132}]},{gen_iq_handler,process_iq,4,[{file,"src/gen_iq_handler.erl"},{line,111}]},{ejabberd_local,route,1,[{file,"src/ejabberd_local.erl"},{line,72}]},{ejabberd_router,do_route,1,[{file,"src/ejabberd_router.erl"},{line,368}]},{ejabberd_router,route,1,[{file,"src/ejabberd_router.erl"},{line,92}]},{ejabberd_c2s,check_privacy_then_route,2,[{file,"src/ejabberd_c2s.erl"},{line,826}]},{xmpp_stream_in,process_authenticated_packet,2,[{file,"src/xmpp_stream_in.erl"},{line,637}]}]}}
[debug] route:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] local route:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] processing packet to full JID:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] sending to process <0.523.0>:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] Won't add stanza for caLmPSeeWQo@example.com/Smack to CSI queue
[info] (tcp|<0.523.0>) Send XML on stream = <<"<a h='5' xmlns='urn:xmpp:sm:3'/>">>
[debug] Flushing packets of @example.com from CSI queue of caLmPSeeWQo@example.com/Smack
[info] (tcp|<0.523.0>) Send XML on stream = <<"<iq xml:lang='en' to='caLmPSeeWQo@example.com/Smack' from='example.com' type='error' id='tZU4h-20'><query xmlns='ns:custom'><abc op='sum'/></query><error code='500' type='wait'><internal-server-error xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Module failed to handle the query</text></error></iq>">>
[info] (tcp|<0.523.0>) Send XML on stream = <<"<r xmlns='urn:xmpp:sm:3'/>">>
[debug] caLmPSeeWQo@example.com/Smack acknowledged 7 of 7 stanzas
[info] (tcp|<0.523.0>) Received XML on stream = <<"<a xmlns='urn:xmpp:sm:3' h='7'/>">>
I have followed these steps to register a custom iq https://github.com/processone/xmpp/issues/9 but still no luck.This is the element which I added in my xmpp/specs/xmpp_codec.spec file
-xml(response,
#elem{name = <<"query">>,
xmlns = <<"ns:custom">>,
module = mod_custom,
result = {response, '$op','$val'},
attrs = [#attr{name = <<"op">>},
#attr{name = <<"val">>}]}).
Am I missing something or is there any change in the way it should be done in ejabberd-18.09?
erlang xmpp ejabberd ejabberd-module ejabberd-hooks
I am trying to move to ejabberd-18.09 from ejabberd-17.03. I have this module so that I can send custom iq stanzas to ejabberd.
-module(mod_test_custom).
%% ====================================================================
%% API functions
%% ====================================================================
-export([start/2, stop/1, process_local_iq/3,depends/2,mod_opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
%% ====================================================================
%% Internal functions
%% ====================================================================
-define(NS_IQ_CUSTOM, <<"ns:custom">>).
start(Host, Opts) ->
IQDisc = gen_mod:get_opt(iqdisc, Opts, fun gen_iq_handler:check_type/1,
one_queue),
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM, ?MODULE, process_local_iq, IQDisc),
xmpp:register_codec(mod_custom),
?INFO_MSG("Inside mod_test_custom”,),
ok.
stop(Host) ->
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_IQ_CUSTOM),
xmpp:unregister_codec(mod_custom),
ok.
depends(_Host, _Opts)->[{?MODULE,soft}].
mod_opt_type(_Option)->
.
process_local_iq(From,To,{iq, ID, get, NS, Language, SubElement} = IQ)->
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[IQ]),
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[From]),
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[To]),
{ _,ID , Type, Feature, Lang, {_,_,_,Sub_els} } = IQ,
Type,Lang,ID,Feature,
?INFO_MSG("Inside mod_test_custom, IQ is ~p~n ",[Sub_els]),
Sum = 2+2,
FoundSubEls = list_to_binary(integer_to_list(Sum)),
SubElement,
{iq, ID, result, NS, Language,[{xmlel,<<"query">>,[{<<"xmlns">>,<<"ns:custom">>}],[{xmlel,<<"response">>,[{<<"op">>,<<"sum">>},{<<"val">>,FoundSubEls}],}]}]}.
This module works fine with ejabberd-17.03 . But when I use it with ejabberd-18.09 I get the following error:
[info] (tcp|<0.523.0>) Received XML on stream = <<"<iq to='example.com' id='tZU4h-20' type='get'><query xmlns='ns:custom'><abc op='sum'></abc></query></iq><r xmlns='urn:xmpp:sm:3'/>">>
[debug] route:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
[debug] local route:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
[error] failed to process iq:
#iq{id = <<"tZU4h-20">>,type = get,lang = <<"en">>,
from =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
to =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]}],
meta = #{ip => {}}}
Reason = {error,{undef,[{mod_test_custom,process_local_iq,[{iq,<<"tZU4h-20">>,get,<<"en">>,{jid,<<"caLmPSeeWQo">>,<<"example.com">>,<<"Smack">>,<<"caLmPSeeWQo">>,<<"example.com">>,<<"Smack">>},{jid,<<>>,<<"example.com">>,<<>>,<<>>,<<"example.com">>,<<>>},[{response,<<>>,<<>>}],#{ip => {}}}],},{gen_iq_handler,process_iq,3,[{file,"src/gen_iq_handler.erl"},{line,132}]},{gen_iq_handler,process_iq,4,[{file,"src/gen_iq_handler.erl"},{line,111}]},{ejabberd_local,route,1,[{file,"src/ejabberd_local.erl"},{line,72}]},{ejabberd_router,do_route,1,[{file,"src/ejabberd_router.erl"},{line,368}]},{ejabberd_router,route,1,[{file,"src/ejabberd_router.erl"},{line,92}]},{ejabberd_c2s,check_privacy_then_route,2,[{file,"src/ejabberd_c2s.erl"},{line,826}]},{xmpp_stream_in,process_authenticated_packet,2,[{file,"src/xmpp_stream_in.erl"},{line,637}]}]}}
[debug] route:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] local route:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] processing packet to full JID:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] sending to process <0.523.0>:
#iq{id = <<"tZU4h-20">>,type = error,lang = <<"en">>,
from =
#jid{
user = <<>>,server = <<"example.com">>,resource = <<>>,luser = <<>>,
lserver = <<"example.com">>,lresource = <<>>},
to =
#jid{
user = <<"caLmPSeeWQo">>,server = <<"example.com">>,
resource = <<"Smack">>,luser = <<"caLmPSeeWQo">>,
lserver = <<"example.com">>,lresource = <<"Smack">>},
sub_els =
[#xmlel{
name = <<"query">>,
attrs = [{<<"xmlns">>,<<"ns:custom">>}],
children =
[#xmlel{
name = <<"abc">>,
attrs = [{<<"op">>,<<"sum">>}],
children = }]},
#stanza_error{
type = wait,code = 500,by = <<>>,
reason = 'internal-server-error',
text =
[#text{
lang = <<"en">>,
data = <<"Module failed to handle the query">>}],
sub_els = }],
meta = #{ip => {}}}
[debug] Won't add stanza for caLmPSeeWQo@example.com/Smack to CSI queue
[info] (tcp|<0.523.0>) Send XML on stream = <<"<a h='5' xmlns='urn:xmpp:sm:3'/>">>
[debug] Flushing packets of @example.com from CSI queue of caLmPSeeWQo@example.com/Smack
[info] (tcp|<0.523.0>) Send XML on stream = <<"<iq xml:lang='en' to='caLmPSeeWQo@example.com/Smack' from='example.com' type='error' id='tZU4h-20'><query xmlns='ns:custom'><abc op='sum'/></query><error code='500' type='wait'><internal-server-error xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/><text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'>Module failed to handle the query</text></error></iq>">>
[info] (tcp|<0.523.0>) Send XML on stream = <<"<r xmlns='urn:xmpp:sm:3'/>">>
[debug] caLmPSeeWQo@example.com/Smack acknowledged 7 of 7 stanzas
[info] (tcp|<0.523.0>) Received XML on stream = <<"<a xmlns='urn:xmpp:sm:3' h='7'/>">>
I have followed these steps to register a custom iq https://github.com/processone/xmpp/issues/9 but still no luck.This is the element which I added in my xmpp/specs/xmpp_codec.spec file
-xml(response,
#elem{name = <<"query">>,
xmlns = <<"ns:custom">>,
module = mod_custom,
result = {response, '$op','$val'},
attrs = [#attr{name = <<"op">>},
#attr{name = <<"val">>}]}).
Am I missing something or is there any change in the way it should be done in ejabberd-18.09?
erlang xmpp ejabberd ejabberd-module ejabberd-hooks
erlang xmpp ejabberd ejabberd-module ejabberd-hooks
edited Nov 23 '18 at 4:27
abhishek ranjan
asked Nov 22 '18 at 6:24
abhishek ranjanabhishek ranjan
98111
98111
The relevant part of the error:undef,[{mod_test_custom,process_local_iq
. That is, the functionmod_test_custom:process_local_iq
is undefined, most likely because themod_test_custom
module cannot be loaded. Where is the filemod_test_custom.beam
located?
– legoscia
Nov 22 '18 at 9:58
1
It is placed with the other .beam files of ejabberd i.e inside usr/local/lib/ejabberd-18.09/ebin folder. plus I have double checked it that it's entry is made in the modules section of ejabberd.yml
– abhishek ranjan
Nov 22 '18 at 10:02
That's strange, I would expect the module to be loaded automatically in that case...
– legoscia
Nov 22 '18 at 10:04
yes exactly, this is where it confuses me.
– abhishek ranjan
Nov 22 '18 at 10:06
1
Ah, you're right! I misread the error message. The problem is that ejabberd callsmod_test_custom:process_local_iq
with one argument, but your function expects three arguments. Looks like it gets called with an#iq{}
record, but not sure where that is defined...
– legoscia
Nov 23 '18 at 9:25
|
show 1 more comment
The relevant part of the error:undef,[{mod_test_custom,process_local_iq
. That is, the functionmod_test_custom:process_local_iq
is undefined, most likely because themod_test_custom
module cannot be loaded. Where is the filemod_test_custom.beam
located?
– legoscia
Nov 22 '18 at 9:58
1
It is placed with the other .beam files of ejabberd i.e inside usr/local/lib/ejabberd-18.09/ebin folder. plus I have double checked it that it's entry is made in the modules section of ejabberd.yml
– abhishek ranjan
Nov 22 '18 at 10:02
That's strange, I would expect the module to be loaded automatically in that case...
– legoscia
Nov 22 '18 at 10:04
yes exactly, this is where it confuses me.
– abhishek ranjan
Nov 22 '18 at 10:06
1
Ah, you're right! I misread the error message. The problem is that ejabberd callsmod_test_custom:process_local_iq
with one argument, but your function expects three arguments. Looks like it gets called with an#iq{}
record, but not sure where that is defined...
– legoscia
Nov 23 '18 at 9:25
The relevant part of the error:
undef,[{mod_test_custom,process_local_iq
. That is, the function mod_test_custom:process_local_iq
is undefined, most likely because the mod_test_custom
module cannot be loaded. Where is the file mod_test_custom.beam
located?– legoscia
Nov 22 '18 at 9:58
The relevant part of the error:
undef,[{mod_test_custom,process_local_iq
. That is, the function mod_test_custom:process_local_iq
is undefined, most likely because the mod_test_custom
module cannot be loaded. Where is the file mod_test_custom.beam
located?– legoscia
Nov 22 '18 at 9:58
1
1
It is placed with the other .beam files of ejabberd i.e inside usr/local/lib/ejabberd-18.09/ebin folder. plus I have double checked it that it's entry is made in the modules section of ejabberd.yml
– abhishek ranjan
Nov 22 '18 at 10:02
It is placed with the other .beam files of ejabberd i.e inside usr/local/lib/ejabberd-18.09/ebin folder. plus I have double checked it that it's entry is made in the modules section of ejabberd.yml
– abhishek ranjan
Nov 22 '18 at 10:02
That's strange, I would expect the module to be loaded automatically in that case...
– legoscia
Nov 22 '18 at 10:04
That's strange, I would expect the module to be loaded automatically in that case...
– legoscia
Nov 22 '18 at 10:04
yes exactly, this is where it confuses me.
– abhishek ranjan
Nov 22 '18 at 10:06
yes exactly, this is where it confuses me.
– abhishek ranjan
Nov 22 '18 at 10:06
1
1
Ah, you're right! I misread the error message. The problem is that ejabberd calls
mod_test_custom:process_local_iq
with one argument, but your function expects three arguments. Looks like it gets called with an #iq{}
record, but not sure where that is defined...– legoscia
Nov 23 '18 at 9:25
Ah, you're right! I misread the error message. The problem is that ejabberd calls
mod_test_custom:process_local_iq
with one argument, but your function expects three arguments. Looks like it gets called with an #iq{}
record, but not sure where that is defined...– legoscia
Nov 23 '18 at 9:25
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424985%2fmodule-to-handle-custom-iq-stanzas-does-not-work-with-ejabberd-18-09%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424985%2fmodule-to-handle-custom-iq-stanzas-does-not-work-with-ejabberd-18-09%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The relevant part of the error:
undef,[{mod_test_custom,process_local_iq
. That is, the functionmod_test_custom:process_local_iq
is undefined, most likely because themod_test_custom
module cannot be loaded. Where is the filemod_test_custom.beam
located?– legoscia
Nov 22 '18 at 9:58
1
It is placed with the other .beam files of ejabberd i.e inside usr/local/lib/ejabberd-18.09/ebin folder. plus I have double checked it that it's entry is made in the modules section of ejabberd.yml
– abhishek ranjan
Nov 22 '18 at 10:02
That's strange, I would expect the module to be loaded automatically in that case...
– legoscia
Nov 22 '18 at 10:04
yes exactly, this is where it confuses me.
– abhishek ranjan
Nov 22 '18 at 10:06
1
Ah, you're right! I misread the error message. The problem is that ejabberd calls
mod_test_custom:process_local_iq
with one argument, but your function expects three arguments. Looks like it gets called with an#iq{}
record, but not sure where that is defined...– legoscia
Nov 23 '18 at 9:25