[ejabberd] Crash while returning IQ packet from Custom IQ handler.

Gaurav Jain monkeyfdude at gmail.com
Mon Mar 2 00:21:43 MSK 2015


* I have written a custom IQ handler
* That handler receives the IQ packet, sets its type = result and returns
back as it output

While testing, custom IQ handler, I get the error mentioned below:

Sequence of events that happened:

* Client sent the below XML to the server.
* Server received it.
* Gives it to the call back function of my custom IQ handler.
* which logs it and make type = result for the IQ packet

* And the server crashes with the result below.

 CRASH REPORT Process <0.473.0> with 0 neighbours exited with reason:
in xml:element_to_string/1 line 122 in p1_fsm:terminate/8 line 760

<?xml version="1.0" encoding="UTF-8"?><iq type="set" id="12345">
   <query xmlns="test:testing">

Relevant Code:

start(Host, Opt) ->
    IQDisc = gen_mod:get_opt(iqdisc, Opt, fun gen_iq_handler:check_type/1,
    gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_TEST,
?MODULE, process_sm_iq, IQDisc).

stop(Host) ->
    gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_TEST),
    error_logger:info_msg("Stoping module 'custom_test' ", []).

process_sm_iq(From, To,
              #iq{type = Type, sub_el = SubEl} = IQ) ->
    error_logger:info_msg("Process_sm_iq request received ~p~n", [IQ]),
    IQ#iq{type = result}.

Please provide pointers to help me resolve this issue.

Best Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.jabber.ru/pipermail/ejabberd/attachments/20150301/7c560d31/attachment.html>

More information about the ejabberd mailing list