0
votes

I'm developing an Android Chat app and i'm trying to run the Erlang module mod_confirm_delivery in order to receive all the messages sent when the user suddenly lose the internet connection (but still appears online on the server). The module start correctly but doesn't works on Ejabberd 16.03, in fact all the messages sent to the "offline" user are lost, i've made some adaptations because the module was created for an older version of Ejabberd, but seems is not enough for make it working. I state that i don't know Erlang and Mnesia db very well, so don't know how to fix the problem.

Here there are the module and the log produced when user 1 try to message to "offline" user 2.

%% name of module must match file name
-module(mod_confirm_delivery).

-author("Johan Vorster").

%% Every ejabberd module implements the gen_mod behavior
%% The gen_mod behavior requires two functions: start/2 and stop/1
-behaviour(gen_mod).

%% public methods for this module
-export([start/2, stop/1, send_packet/4, receive_packet/5, get_session/5, set_offline_message/5]).

%% included for writing to ejabberd log file
-include("ejabberd.hrl").
-include("logger.hrl").

-record(session, {sid, usr, us, priority, info}).
-record(offline_msg, {us, timestamp, expire, from, to, packet}).
-record(confirm_delivery, {messageid, timerref}).

start(_Host, _Opt) -> 

    ?DEBUG("mod_confirm_delivery loading", []),
    mnesia:create_table(confirm_delivery, 
        [{attributes, record_info(fields, confirm_delivery)}]),
    mnesia:clear_table(confirm_delivery),
    ?DEBUG("created timer ref table", []),

    ?DEBUG("start user_send_packet hook", []),
    ejabberd_hooks:add(user_send_packet, _Host, ?MODULE, send_packet, 50),   
    ?DEBUG("start user_receive_packet hook", []),
    ejabberd_hooks:add(user_receive_packet, _Host, ?MODULE, receive_packet, 50).   

stop(_Host) -> 
    ?DEBUG("stopping mod_confirm_delivery", []),
    ejabberd_hooks:delete(user_send_packet, _Host, ?MODULE, send_packet, 50),
    ejabberd_hooks:delete(user_receive_packet, _Host, ?MODULE, receive_packet, 50). 

%%send_packet(From, To, Packet) ->
send_packet(Packet, C2SState, From, To) ->  
%% ?INFO_MSG("send_packet FromJID ~p ToJID ~p Packet ~p~n",[From, To, Packet]),
?DEBUG("send_packet Packet ~p C2SState ~p FromJID ~p ToJID ~p~n",[Packet, C2SState, From, To]),   

Type = fxml:get_tag_attr_s(<<"type">>, Packet),
?DEBUG("Message Type ~p~n",[Type]),

Body = fxml:get_path_s(Packet, [{elem, <<"body">>}, cdata]), 
?DEBUG("Message Body ~p~n",[Body]),

MessageId = fxml:get_tag_attr_s(<<"id">>, Packet),
?DEBUG("send_packet MessageId ~p~n",[MessageId]), 

LUser = element(2, To),
?DEBUG("send_packet LUser ~p~n",[LUser]), 

LServer = element(3, To), 
?DEBUG("send_packet LServer ~p~n",[LServer]), 

Sessions = mnesia:dirty_index_read(session, {LUser, LServer}, #session.us),
?DEBUG("Session: ~p~n",[Sessions]),

case Type =:= "chat" andalso Body =/= [] andalso Sessions =/= [] of
    true ->                

    {ok, Ref} = timer:apply_after(10000, mod_confirm_delivery, get_session, [LUser, LServer, From, To, Packet]),

    ?DEBUG("Saving To ~p Ref ~p~n",[MessageId, Ref]),

    F = fun() ->
        mnesia:write(#confirm_delivery{messageid=MessageId, timerref=Ref})
    end,

    mnesia:transaction(F);

_ ->
    Packet
end.   

receive_packet(Packet, C2SState, _JID, From, To) ->
?DEBUG("receive_packet JID: ~p From: ~p To: ~p Packet: ~p~n",[_JID, From, To, Packet]), 

Received = fxml:get_subtag(Packet, <<"received">>), 
?DEBUG("receive_packet Received Tag ~p~n",[Received]),    

if Received =/= false andalso Received =/= [] ->
    MessageId = fxml:get_tag_attr_s(<<"id">>, Received),
    ?DEBUG("receive_packet MessageId ~p~n",[MessageId]);       
true ->
    MessageId = []
end, 

if MessageId =/= [] ->
    Record = mnesia:dirty_read(confirm_delivery, MessageId),
    ?DEBUG("receive_packet Record: ~p~n",[Record]);       
true ->
    Record = []
end, 

if Record =/= [] ->
    [R] = Record,
    ?DEBUG("receive_packet Record Elements ~p~n",[R]), 

    Ref = element(3, R),

    ?DEBUG("receive_packet Cancel Timer ~p~n",[Ref]), 
    timer:cancel(Ref),

    mnesia:dirty_delete(confirm_delivery, MessageId),
    ?DEBUG("confirm_delivery clean up",[]);     
true ->
    Packet
end.


get_session(User, Server, From, To, Packet) ->   
?DEBUG("get_session User: ~p Server: ~p From: ~p To ~p Packet ~p~n",[User, Server, From, To, Packet]),   

ejabberd_router:route(From, To, Packet),
?DEBUG("Resend message",[]),

set_offline_message(User, Server, From, To, Packet),
?DEBUG("Set offline message",[]),

MessageId = fxml:get_tag_attr_s(<<"id">>, Packet), 
?DEBUG("get_session MessageId ~p~n",[MessageId]),    

case MessageId =/= [] of
    true ->        

    mnesia:dirty_delete(confirm_delivery, MessageId),
    ?DEBUG("confirm_delivery clean up",[]);

 _ ->
    ok
end.

set_offline_message(User, Server, From, To, Packet) ->
?DEBUG("set_offline_message User: ~p Server: ~p From: ~p To ~p Packet ~p~n",[User, Server, From, To, Packet]),    

F = fun() ->
    mnesia:write(#offline_msg{us = {User, Server}, timestamp = now(), expire = "never", from = From, to = To, packet = Packet})
end,

mnesia:transaction(F).

log

2016-10-26 16:24:26.320 [debug] <0.6745.7>@ejabberd_sm:do_route:420 session manager
        from {jid,<<"2">>,<<"mydomain.com">>,<<>>,<<"2">>,<<"mydomain.com">>,<<>>}
        to {jid,<<"1">>,<<"mydomain.com">>,<<>>,<<"1">>,<<"mydomain.com">>,<<>>}
        packet {xmlel,<<"presence">>,[{<<"type">>,<<"subs"...>>}],[]}
2016-10-26 16:24:26.345 [debug] <0.6744.7>@ejabberd_receiver:process_data:284 Received XML on stream = <<"<iq to='mydomain.com' id='POJeY-45' type='set'><register xmlns='https://android.googleapis.com/gcm'><key>doyCwvN_NNk:APA91bEx80MxaQ0Nj7wXhlvEUpJgG6bBLqmuyR3XiQaK-pCO7ftVtD1DsYB8RErepCKsutDSjMZP6g9hCvaQGshG9GUY7E8kKSxYy21MI_Agf_WC2WdcNSHwmNoO53AX4Rkqvhrfzfu0</key></register></iq><message to='[email protected]' id='2831541994867' type='chat'><body>{&quot;Date&quot;:&quot;26 ott 2016&quot;,&quot;Time&quot;:&quot;1477491866&quot;,&quot;body&quot;:&quot;hello2&quot;,&quot;isMine&quot;:true,&quot;msgid&quot;:&quot;2831541994867&quot;,&quot;random_id&quot;:&quot;802726696&quot;,&quot;reason&quot;:&quot;chat&quot;,&quot;receiver&quot;:&quot;2&quot;,&quot;sender&quot;:&quot;1&quot;,&quot;senderName&quot;:&quot;1&quot;}</body><thread>4d8f64fb-7012-4649-a123-9dd7873132dd</thread></message><r xmlns='urn:xmpp:sm:3'/>">>
2016-10-26 16:24:26.345 [debug] <0.6744.7>@shaper:update:120 State: {maxrate,1000,496.7201044401154,1477491866318200}, Size=824
M=548.1347834383881, I=27.194
2016-10-26 16:24:26.346 [info] <0.6745.7>@mod_confirm_delivery:send_packet:42 send_packet Packet {xmlel,<<"iq">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<"mydomain.com">>},{<<"id">>,<<"POJeY-45">>},{<<"type">>,<<"set">>}],[{xmlel,<<"register">>,[{<<"xmlns">>,<<"https://android.googleapis.com/gcm">>}],[{xmlel,<<"key">>,[],[{xmlcdata,<<"doyCwvN_NNk:APA91bEx80MxaQ0Nj7wXhlvEUpJgG6bBLqmuyR3XiQaK-pCO7ftVtD1DsYB8RErepCKsutDSjMZP6g9hCvaQGshG9GUY7E8kKSxYy21MI_Agf_WC2WdcNSHwmNoO53AX4Rkqvhrfzfu0">>}]}]}]} C2SState {state,{socket_state,fast_tls,{tlssock,#Port<0.637892>,#Port<0.637893>},<0.6744.7>},ejabberd_socket,#Ref<0.0.1572865.84391>,false,<<"6182426231480078240">>,undefined,c2s,c2s_shaper,false,true,true,true,[verify_none,compression_none,{certfile,<<"/etc/ejabberd/ejabberd.pem">>}],true,{jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>},<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,{{1477,489252,221181},<0.6745.7>},{3,{{<<"2">>,<<"mydomain.com">>,<<>>},{{<<"1">>,<<"mydomain.com">>,<<>>},nil,nil},{{<<"3">>,<<"mydomain.com">>,<<>>},nil,nil}}},{3,{{<<"2">>,<<"mydomain.com">>,<<>>},{{<<"1">>,<<"mydomain.com">>,<<>>},nil,nil},{{<<"3">>,<<"mydomain.com">>,<<>>},nil,nil}}},{3,{{<<"1">>,<<"mydomain.com">>,<<>>},nil,{{<<"2">>,<<"mydomain.com">>,<<>>},nil,{{<<"3">>,<<"mydomain.com">>,<<>>},nil,nil}}}},{xmlel,<<"presence">>,[{<<"xml:lang">>,<<"en">>},{<<"id">>,<<"POJeY-6">>}],[{xmlel,<<"c">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/caps">>},{<<"hash">>,<<"sha-1">>},{<<"node">>,<<"http://www.igniterealtime.org/projects/smack">>},{<<"ver">>,<<"NfJ3flI83zSdUDzCEICtbypursw=">>}],[]}]},...} FromJID {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>} ToJID {jid,<<>>,<<"mydomain.com">>,<<>>,<<>>,<<"mydomain.com">>,<<>>}
2016-10-26 16:24:26.346 [info] <0.6745.7>@mod_confirm_delivery:send_packet:45 Message Type <<"set">>
2016-10-26 16:24:26.346 [info] <0.6745.7>@mod_confirm_delivery:send_packet:48 Message Body <<>>
2016-10-26 16:24:26.346 [info] <0.6745.7>@mod_confirm_delivery:send_packet:51 send_packet MessageId <<"POJeY-45">>
2016-10-26 16:24:26.346 [info] <0.6745.7>@mod_confirm_delivery:send_packet:54 send_packet LUser <<>>
2016-10-26 16:24:26.346 [info] <0.6745.7>@mod_confirm_delivery:send_packet:57 send_packet LServer <<"mydomain.com">>
2016-10-26 16:24:26.346 [info] <0.6745.7>@mod_confirm_delivery:send_packet:60 Session: []
2016-10-26 16:24:26.346 [debug] <0.6745.7>@ejabberd_router:do_route:351 route
        from {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>}
        to {jid,<<>>,<<"mydomain.com">>,<<>>,<<>>,<<"mydomain.com">>,<<>>}
        packet {xmlel,<<"iq">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<"mydomain.com">>},{<<"id">>,<<"POJeY-45">>},{<<"type">>,<<"set">>}],[{xmlel,<<"register">>,[{<<"xmlns">>,<<"https://android.googleapis.com/gcm">>}],[{xmlel,<<"key">>,[],[{xmlcdata,<<"doyCwvN_NNk:APA91bEx80MxaQ0Nj7wXhlvEUpJgG6bBLqmuyR3XiQaK-pCO7ftVtD1DsYB8RErepCKsutDSjMZP6g9hCvaQGshG9GUY7E8kKSxYy21MI_Agf_WC2WdcNSHwmNoO53AX4Rkqvhrfzfu0">>}]}]}]}
2016-10-26 16:24:26.347 [debug] <0.6745.7>@ejabberd_local:do_route:261 local route
        from {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>}
        to {jid,<<>>,<<"mydomain.com">>,<<>>,<<>>,<<"mydomain.com">>,<<>>}
        packet {xmlel,<<"iq">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<...>>},{<<...>>,...},{...}],[{xmlel,<<...>>,...}]}
2016-10-26 16:24:26.347 [debug] <0.6745.7>@mod_gcm:iq:156 mod_gcm: updating last_seen for user [email protected]
2016-10-26 16:24:26.347 [debug] <0.6745.7>@ejabberd_router:do_route:351 route
        from {jid,<<>>,<<"mydomain.com">>,<<>>,<<>>,<<"mydomain.com">>,<<>>}
        to {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>}
        packet {xmlel,<<"iq">>,[{<<"id">>,<<"POJeY-45">>},{<<"type">>,<<"result">>}],[]}
2016-10-26 16:24:26.347 [debug] <0.6745.7>@ejabberd_local:do_route:261 local route
        from {jid,<<>>,<<"mydomain.com">>,<<>>,<<>>,<<"mydomain.com">>,<<>>}
        to {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>}
        packet {xmlel,<<"iq">>,[{<<"id">>,<<"POJe"...>>},{<<"type">>,<<...>>}],[]}
2016-10-26 16:24:26.347 [debug] <0.6745.7>@ejabberd_sm:do_route:420 session manager
        from {jid,<<>>,<<"mydomain.com">>,<<>>,<<>>,<<"mydomain.com">>,<<>>}
        to {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>}
        packet {xmlel,<<"iq">>,[{<<"id">>,<<"POJe"...>>},{<<"type">>,<<...>>}],[]}
2016-10-26 16:24:26.348 [debug] <0.6745.7>@ejabberd_sm:do_route:538 sending to process <0.6745.7>
2016-10-26 16:24:26.348 [info] <0.6745.7>@mod_confirm_delivery:send_packet:42 send_packet Packet {xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<"[email protected]">>},{<<"id">>,<<"2831541994867">>},{<<"type">>,<<"chat">>}],[{xmlel,<<"body">>,[],[{xmlcdata,<<"{\"Date\":\"26 ott 2016\",\"Time\":\"1477491866\",\"body\":\"hello2\",\"isMine\":true,\"msgid\":\"2831541994867\",\"random_id\":\"802726696\",\"reason\":\"chat\",\"receiver\":\"2\",\"sender\":\"1\",\"senderName\":\"1\"}">>}]},{xmlel,<<"thread">>,[],[{xmlcdata,<<"4d8f64fb-7012-4649-a123-9dd7873132dd">>}]}]} C2SState {state,{socket_state,fast_tls,{tlssock,#Port<0.637892>,#Port<0.637893>},<0.6744.7>},ejabberd_socket,#Ref<0.0.1572865.84391>,false,<<"6182426231480078240">>,undefined,c2s,c2s_shaper,false,true,true,true,[verify_none,compression_none,{certfile,<<"/etc/ejabberd/ejabberd.pem">>}],true,{jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>},<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,{{1477,489252,221181},<0.6745.7>},{3,{{<<"2">>,<<"mydomain.com">>,<<>>},{{<<"1">>,<<"mydomain.com">>,<<>>},nil,nil},{{<<"3">>,<<"mydomain.com">>,<<>>},nil,nil}}},{3,{{<<"2">>,<<"mydomain.com">>,<<>>},{{<<"1">>,<<"mydomain.com">>,<<>>},nil,nil},{{<<"3">>,<<"mydomain.com">>,<<>>},nil,nil}}},{3,{{<<"1">>,<<"mydomain.com">>,<<>>},nil,{{<<"2">>,<<"mydomain.com">>,<<>>},nil,{{<<"3">>,<<"mydomain.com">>,<<>>},nil,nil}}}},{xmlel,<<"presence">>,[{<<"xml:lang">>,<<"en">>},{<<"id">>,<<"POJeY-6">>}],[{xmlel,<<"c">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/caps">>},{<<"hash">>,<<"sha-1">>},{<<"node">>,<<"http://www.igniterealtime.org/projects/smack">>},{<<"ver">>,<<"NfJ3flI83z...">>}],...}]},...} FromJID {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>} ToJID {jid,<<"2">>,<<"mydomain.com">>,<<>>,<<"2">>,<<"mydomain.com">>,<<>>}
2016-10-26 16:24:26.348 [info] <0.6745.7>@mod_confirm_delivery:send_packet:45 Message Type <<"chat">>
2016-10-26 16:24:26.348 [info] <0.6745.7>@mod_confirm_delivery:send_packet:48 Message Body <<"{\"Date\":\"26 ott 2016\",\"Time\":\"1477491866\",\"body\":\"hello2\",\"isMine\":true,\"msgid\":\"2831541994867\",\"random_id\":\"802726696\",\"reason\":\"chat\",\"receiver\":\"2\",\"sender\":\"1\",\"senderName\":\"1\"}">>
2016-10-26 16:24:26.348 [info] <0.6745.7>@mod_confirm_delivery:send_packet:51 send_packet MessageId <<"2831541994867">>
2016-10-26 16:24:26.348 [info] <0.6745.7>@mod_confirm_delivery:send_packet:54 send_packet LUser <<"2">>
2016-10-26 16:24:26.348 [info] <0.6745.7>@mod_confirm_delivery:send_packet:57 send_packet LServer <<"mydomain.com">>
2016-10-26 16:24:26.349 [info] <0.6745.7>@mod_confirm_delivery:send_packet:60 Session: [{session,{{1477,491691,357100},<0.6738.7>},{<<"2">>,<<"mydomain.com">>,<<"dMeXduJ49Zk">>},{<<"2">>,<<"mydomain.com">>},0,[{ip,{{5,90,200,27},26166}},{conn,c2s_tls},{auth_module,undefined}]}]
2016-10-26 16:24:26.349 [debug] <0.6745.7>@ejabberd_local:do_route:261 local route
        from {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>}
        to {jid,<<"2">>,<<"mydomain.com">>,<<>>,<<"2">>,<<"mydomain.com">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<...>>},{<<...>>,...},{...}],[{xmlel,<<...>>,...},{xmlel,...}]}
2016-10-26 16:24:26.349 [debug] <0.6745.7>@ejabberd_sm:do_route:420 session manager
        from {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>}
        to {jid,<<"2">>,<<"mydomain.com">>,<<>>,<<"2">>,<<"mydomain.com">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<...>>},{<<...>>,...},{...}],[{xmlel,<<...>>,...},{xmlel,...}]}
2016-10-26 16:24:26.349 [debug] <0.6745.7>@ejabberd_sm:route_message:584 sending to process <0.6738.7>
2016-10-26 16:24:26.349 [debug] <0.6745.7>@ejabberd_c2s:send_text:1823 Send XML on stream = <<"<a xmlns='urn:xmpp:sm:3' h='20'/>">>
2016-10-26 16:24:26.350 [info] <0.6745.7>@mod_confirm_delivery:receive_packet:80 receive_packet JID: {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>} From: {jid,<<>>,<<"mydomain.com">>,<<>>,<<>>,<<"mydomain.com">>,<<>>} To: {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>} Packet: {xmlel,<<"iq">>,[{<<"from">>,<<"mydomain.com">>},{<<"to">>,<<"[email protected]/doyCwvN_NNk">>},{<<"id">>,<<"POJeY-45">>},{<<"type">>,<<"result">>}],[]}
2016-10-26 16:24:26.350 [info] <0.6745.7>@mod_confirm_delivery:receive_packet:83 receive_packet Received Tag false
2016-10-26 16:24:26.350 [info] <0.6738.7>@mod_confirm_delivery:receive_packet:80 receive_packet JID: {jid,<<"2">>,<<"mydomain.com">>,<<"dMeXduJ49Zk">>,<<"2">>,<<"mydomain.com">>,<<"dMeXduJ49Zk">>} From: {jid,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>,<<"1">>,<<"mydomain.com">>,<<"doyCwvN_NNk">>} To: {jid,<<"2">>,<<"mydomain.com">>,<<>>,<<"2">>,<<"mydomain.com">>,<<>>} Packet: {xmlel,<<"message">>,[{<<"from">>,<<"[email protected]/doyCwvN_NNk">>},{<<"to">>,<<"[email protected]">>},{<<"xml:lang">>,<<"en">>},{<<"id">>,<<"2831541994867">>},{<<"type">>,<<"chat">>}],[{xmlel,<<"body">>,[],[{xmlcdata,<<"{\"Date\":\"26 ott 2016\",\"Time\":\"1477491866\",\"body\":\"hello2\",\"isMine\":true,\"msgid\":\"2831541994867\",\"random_id\":\"802726696\",\"reason\":\"chat\",\"receiver\":\"2\",\"sender\":\"1\",\"senderName\":\"1\"}">>}]},{xmlel,<<"thread">>,[],[{xmlcdata,<<"4d8f64fb-7012-4649-a123-9dd7873132dd">>}]}]}
2016-10-26 16:24:26.350 [debug] <0.6745.7>@ejabberd_c2s:send_text:1823 Send XML on stream = <<"<iq from='mydomain.com' to='[email protected]/doyCwvN_NNk' id='POJeY-45' type='result'/>">>
2016-10-26 16:24:26.350 [debug] <0.6745.7>@ejabberd_c2s:send_text:1823 Send XML on stream = <<"<r xmlns='urn:xmpp:sm:3'/>">>
2016-10-26 16:24:26.350 [info] <0.6738.7>@mod_confirm_delivery:receive_packet:83 receive_packet Received Tag false
2016-10-26 16:24:26.351 [debug] <0.6738.7>@ejabberd_c2s:send_text:1823 Send XML on stream = <<"<message from='[email protected]/doyCwvN_NNk' to='[email protected]' xml:lang='en' id='2831541994867' type='chat'><body>{&quot;Date&quot;:&quot;26 ott 2016&quot;,&quot;Time&quot;:&quot;1477491866&quot;,&quot;body&quot;:&quot;hello2&quot;,&quot;isMine&quot;:true,&quot;msgid&quot;:&quot;2831541994867&quot;,&quot;random_id&quot;:&quot;802726696&quot;,&quot;reason&quot;:&quot;chat&quot;,&quot;receiver&quot;:&quot;2&quot;,&quot;sender&quot;:&quot;1&quot;,&quot;senderName&quot;:&quot;1&quot;}</body><thread>4d8f64fb-7012-4649-a123-9dd7873132dd</thread></message>">>
2016-10-26 16:24:26.351 [debug] <0.6738.7>@ejabberd_c2s:send_text:1823 Send XML on stream = <<"<r xmlns='urn:xmpp:sm:3'/>">>
2016-10-26 16:24:26.867 [debug] <0.6744.7>@ejabberd_receiver:process_data:284 Received XML on stream = <<"<a xmlns='urn:xmpp:sm:3' h='18'/>">>
2016-10-26 16:24:26.867 [debug] <0.6744.7>@shaper:update:120 State: {maxrate,1000,999.7776233539505,1477491866866497}, Size=33
M=32.99266320221285, I=0.751
2016-10-26 16:24:26.867 [debug] <0.6745.7>@ejabberd_c2s:check_h_attribute:2782 [email protected]/doyCwvN_NNk acknowledged 18 of 18 stanzas
2016-10-26 16:24:33.969 [info] <0.16878.5>@ejabberd_listener:accept:333 (#Port<0.637900>) Accepted connection 127.0.0.1:58342 -> 127.0.0.1:5280
2016-10-26 16:24:33.970 [debug] <0.6758.7>@ejabberd_http:init:154 S: [{[<<"websocket">>],ejabberd_http_ws},{[<<"captcha">>],ejabberd_captcha},{[<<"admin">>],ejabberd_web_admin},{[<<"http-bind">>],mod_http_bind}]
2016-10-26 16:24:33.970 [info] <0.6758.7>@ejabberd_http:init:158 started: {gen_tcp,#Port<0.637900>}
2016-10-26 16:24:35.306 [debug] <0.6758.7>@ejabberd_http:process_header:281 (#Port<0.637900>) http query: 'GET' <<"/admin/server/mydomain.com/users/">>
2016-10-26 16:24:35.306 [debug] <0.6758.7>@ejabberd_http:process:353 [<<"admin">>,<<"server">>,<<"mydomain.com">>,<<"users">>] matches [<<"admin">>]
2016-10-26 16:24:36.915 [debug] <0.6758.7>@ejabberd_http:process_header:281 (#Port<0.637900>) http query: 'GET' <<"/admin/server/mydomain.com/users/">>
2016-10-26 16:24:36.915 [debug] <0.6758.7>@ejabberd_http:process:353 [<<"admin">>,<<"server">>,<<"mydomain.com">>,<<"users">>] matches [<<"admin">>]
1

1 Answers

0
votes

ejabberd has stream management option of the c2s listener. You should set option stream_management to true. . You have to also enable stream management from client side (android) after doing this you do not need to implement mod_confirm_delivery. . When the user suddenly lose the internet connection (but still appears online on the server) you can handle this problem by enable mod_ping module in ejabberd server. Reference ejabberd configuration Stream Management reference