0

I was making a custom module and this my code below. I am getting "feature not available error" from server.

-define(NS_USER_PRESENCE, "jabber:iq:userpresence").

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_USER_PRESENCE, ?MODULE, process_local_iq, IQDisc), 
?INFO_MSG("Loading module 'mod_user_presence' ", []).

stop(Host) ->
    gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_USER_PRESENCE),
?INFO_MSG("Bye bye 'mod_user_presence' ", []).

process_local_iq(_From, _To,
    #iq{type = Type, sub_el = SubEl} = IQ) ->
    case Type of
      set ->
          IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]};
      get ->
          Sec = 5,
          IQ#iq{type = result,
          sub_el =
            [#xmlel{name = <<"query">>,
                attrs =
                [{<<"xmlns">>, ?NS_USER_PRESENCE},
                {<<"seconds">>,
                iolist_to_binary(integer_to_list(Sec))}],
          children = []}]}
    end.

when I send the request:

<iq from="user2@localhost" to="user1@localhost" type="get" id="checkcustomXmpp88559"><query xmlns="jabber:iq:userpresence"/>

i get this response from server:

<iq from="user1@localhost" to="user2@localhost/2749575415146350011893958" type="error" id="checkcustomXmpp88559" xmlns:stream="http://etherx.jabber.org/streams">
<query xmlns="jabber:iq:userpresence"/>
<error code='503' type='cancel'>
<service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>

akhileshnair
  • 1,437
  • 1
  • 12
  • 18
  • 1
    Possible duplicate of [Ejabberd custom IQ Handler: getting feature-not-implemented or service-unavailable](http://stackoverflow.com/questions/36346992/ejabberd-custom-iq-handler-getting-feature-not-implemented-or-service-unavailab) – legoscia May 23 '16 at 10:07
  • [This answer](http://stackoverflow.com/a/36352968/113848) should answer your question. – legoscia May 23 '16 at 10:08

0 Answers0