erlangxmppejabberdspawnejabberd-module

ejabberd: spawn own process and route the result back to client


Since, ejabberd no longer supports the iqdisc option. I am trying to create my own custom queue to handle all the iq-packets with a custom namespace and return the result back to the client. I am able to spawn my own process and run the functions and obtain the result. But the process fails in the end with the following error:

09:07:42.850 [error] Failed to route packet:
#iq{id = <<"5b660017-c52c-4fe8-8a56-213c1a86bc12-3">>,type = get,
    lang = <<"en">>,
    from =
        #jid{
            user = <<"check">>,server = <<"localhost">>,
            resource = <<"64195176449188261912514">>,luser = <<"check">>,
            lserver = <<"localhost">>,
            lresource = <<"64195176449188261912514">>},
    to =
        #jid{
            user = <<>>,server = <<"localhost">>,resource = <<>>,luser = <<>>,
            lserver = <<"localhost">>,lresource = <<>>},
    sub_els =
        [#xmlel{
             name = <<"....
......
.......
exception error: no try clause matching ok
   in function  gen_iq_handler:process_iq/4 (src/gen_iq_handler.erl, line 110)
   in call from ejabberd_router:do_route/1 (src/ejabberd_router.erl, line 399)
   in call from ejabberd_router:route/1 (src/ejabberd_router.erl, line 92)
   in call from ejabberd_c2s:check_privacy_then_route/2 (src/ejabberd_c2s.erl, line 842)
   in call from xmpp_stream_in:process_authenticated_packet/2 (src/xmpp_stream_in.erl, line 697)
   in call from xmpp_stream_in:handle_info/2 (src/xmpp_stream_in.erl, line 392)
   in call from p1_server:handle_msg/8 (src/p1_server.erl, line 696)
   in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 249)

The packet shown above is from the client to server: which looks fine to me. I am using the latest ejabberd version: 19.09.1 I guess, I am having trouble routing the iq-packet response back to the client? Am I missing something else here? The packet seems fine to me. What is the ideal way to dedicate a queue to process all the iq-packets to a custom namespace and then return the responses back to the client, without blocking the main queue in the meantime, so that ejabberd can still handle other incoming packets.

Any ideas/pointers would be really appreciated. Thanks!


Solution

  • I figured this out. The spawned process was not returning the desired result and hence the request failed. I am still trying to figure out how to process multiple packets (target to different namespaces) at once on ejabberd, so that I can run all packets to my custom namespace to run on a single queue.