royneary / mod_push

Other
68 stars 19 forks source link

Apns. Notification is not sent. #20

Closed alexsandbox closed 7 years ago

alexsandbox commented 7 years ago

Ejabbed 16. I use development certificate. Config:

...
    stream_management: true
    resume_timeout: 300
    resend_on_timeout: true
...
mod_pubsub: 
    host : "pubsub.flash.intellin.ru"
    nodetree : "virtual"
    access_createnode: pubsub_createnode
    plugins: 
      - "flat"
      - "push"
      - "hometree"
      - "pep" 
  mod_push:
    include_senders: true
    include_message_count: true
    include_subscription_count: true
    access_backends: pubsub_createnode
    certfile: "/etc/ejabberd/tls/wss.pem"
    backends:
      -
        type: apns
        app_name: "ru.intellin.hotline.intellin"
        register_host: "flash.intellin.ru"
        pubsub_host: "pubsub.flash.intellin.ru"
        certfile: "------------------aps_final.pem"

Ejabberd debug log:

Success started:

16:51:12.269 [info] added adhoc command handler for app server <<"flash.intellin.ru">>
16:51:12.273 [debug] +++++++++ mod_push_apns:init, certfile = <<"-------/aps_final.pem">>
16:51:12.291 [debug] Supervisor ejabberd_sup started gen_server:start_link({local,'apns_flash.intellin.ru'}, mod_push_apns, [undefined,undefined,<<"---------aps_final.pem">>], []) at pid <0.476.0>
16:51:12.292 [debug] ++++++++ Added push backends

Register apns:


Received XML on stream = <<"<iq type=\"set\"><enable xmlns=\"urn:xmpp:push:0\" jid=\"pubsub.flash.intellin.ru\" node=\"D9AAAC89-624B-4111-84E5-AB803696EA19\"><x xmlns=\"jabber:x:data\"><field var=\"FORM_TYPE\"><value>http://jabber.org/protocol/pubsub#publish-options</value></field><field var=\"token\"><value>a7661c12280c73edb3e303dcf7949447dbe6e7aa</value></field></x></enable></iq>">>
16:53:57.976 [debug] State: {maxrate,1000,989.5345314956888,1470146037881973}, Size=431
M=426.53609988074635, I=94.874
16:53:57.977 [debug] route
        from {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"iq">>,[{<<"type">>,<<"set">>}],[{xmlel,<<"enable">>,[{<<"xmlns">>,<<"urn:xmpp:push:0">>},{<<"jid">>,<<"pubsub.flash.intellin.ru">>},{<<"node">>,<<"D9AAAC89-624B-4111-84E5-AB803696EA19">>}],[{xmlel,<<"x">>,[{<<"xmlns">>,<<"jabber:x:data">>}],[{xmlel,<<"field">>,[{<<"var">>,<<"FORM_TYPE">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"http://jabber.org/protocol/pubsub#publish-options">>}]}]},{xmlel,<<"field">>,[{<<"var">>,<<"token">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"a7661c12280c73edb3e303dcf7949447dbe6e7aa">>}]}]},{xmlel,<<"field">>,----]}]}]}
16:53:57.977 [debug] local route
        from {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"iq">>,[{<<"type">>,<<"set">>}],[{xmlel,<<...>>,...}]}
16:53:57.977 [debug] session manager
        from {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"iq">>,[{<<"type">>,<<"set">>}],[{xmlel,<<...>>,...}]}
16:53:57.978 [debug] +++++ ParsedSecret = {result,[undefined]}
16:53:57.978 [debug] +++++ enable: no user found!
16:53:57.978 [debug] +++++ ParseResult = not_found
16:53:57.978 [debug] route
        from {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        packet {xmlel,<<"iq">>,[{<<"type">>,<<"result">>}],[]}
16:53:57.979 [debug] local route
        from {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        packet {xmlel,<<"iq">>,[{<<"type">>,<<"resu"...>>}],[]}
16:53:57.979 [debug] session manager
        from {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        packet {xmlel,<<"iq">>,[{<<"type">>,<<"resu"...>>}],[]}
16:53:57.979 [debug] sending to process <0.559.0>
16:53:57.979 [debug] Send XML on stream = <<"<iq from='test@flash.intellin.ru' to='test@flash.intellin.ru/chatsecure27345' type='result'/>">>
16:53:57.979 [debug] Send XML on stream = <<"<r xmlns='urn:xmpp:sm:3'/>">>
16:53:58.309 [debug] Received XML on stream = <<"<iq type=\"set\" to=\"flash.intellin.ru\" id=\"ru.intellin.hotline.intellin\"><command xmlns=\"http://jabber.org/protocol/commands\" node=\"register-push-apns\" action=\"execute\"><x xmlns=\"jabber:x:data\" type=\"submit\"><field var=\"token\"><value>20995c2c52e6d761114df8375af1c4f739482863a9af12cf9a9e08b8c19db954</value></field><field var=\"device-name\"><value>Home</value></field></x></command></iq><a xmlns=\"urn:xmpp:sm:3\" h=\"6\"/>">>
16:53:58.310 [debug] State: {maxrate,1000,999.433378179492,1470146038308988}, Size=416
M=415.7644188081125, I=1.078
16:53:58.310 [debug] route
        from {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        to {jid,<<>>,<<"flash.intellin.ru">>,<<>>,<<>>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"iq">>,[{<<"type">>,<<"set">>},{<<"to">>,<<"flash.intellin.ru">>},{<<"id">>,<<"ru.intellin.hotline.intellin">>}],[{xmlel,<<"command">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/commands">>},{<<"node">>,<<"register-push-apns">>},{<<"action">>,<<"execute">>}],[{xmlel,<<"x">>,[{<<"xmlns">>,<<"jabber:x:data">>},{<<"type">>,<<"submit">>}],[{xmlel,<<"field">>,[{<<"var">>,<<"token">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"20995c2c52e6d761114df8375af1c4f739482863a9af12cf9a9e08b8c19db954">>}]}]},{xmlel,<<"field">>,[{<<"var">>,<<"device-name">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"Home">>}]}]}]}]}]}
16:53:58.310 [debug] local route
        from {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        to {jid,<<>>,<<"flash.intellin.ru">>,<<>>,<<>>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"iq">>,[{<<"type">>,<<"set">>},{<<"to">>,<<...>>},{<<...>>,...}],[{xmlel,<<...>>,...}]}
16:53:58.310 [debug] test@flash.intellin.ru/chatsecure27345 acknowledged 6 of 6 stanzas
16:53:58.311 [debug] About to parse {iq,<<"ru.intellin.hotline.intellin">>,set,<<"http://jabber.org/protocol/commands">>,<<>>,{xmlel,<<"command">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/commands">>},{<<"node">>,<<"register-push-apns">>},{<<"action">>,<<"execute">>}],[{xmlel,<<"x">>,[{<<"xmlns">>,<<"jabber:x:data">>},{<<"type">>,<<"submit">>}],[{xmlel,<<"field">>,[{<<"var">>,<<"token">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"20995c2c52e6d761114df8375af1c4f739482863a9af12cf9a9e08b8c19db954">>}]}]},{xmlel,<<"field">>,[{<<"var">>,<<"device-name">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"Home">>}]}]}]}]}}...
16:53:58.311 [debug] entering parse_request...
16:53:58.315 [debug] +++++ register_client: found backend
16:53:58.316 [debug] route
        from {jid,<<>>,<<"flash.intellin.ru">>,<<>>,<<>>,<<"flash.intellin.ru">>,<<>>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        packet {xmlel,<<"iq">>,[{<<"id">>,<<"ru.intellin.hotline.intellin">>},{<<"type">>,<<"result">>}],[{xmlel,<<"command">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/commands">>},{<<"sessionid">>,<<"2016-08-02T13:53:58.316143Z">>},{<<"node">>,<<"register-push-apns">>},{<<"status">>,<<"completed">>}],[{xmlel,<<"x">>,[{<<"xmlns">>,<<"jabber:x:data">>},{<<"type">>,<<"result">>}],[{xmlel,<<"field">>,[{<<"var">>,<<"jid">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"pubsub.flash.intellin.ru">>}]}]},{xmlel,<<"field">>,[{<<"var">>,<<"node">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"10999554424259493740">>}]}]},{xmlel,<<"field">>,[{<<"var">>,<<"secret">>}],[{xmlel,<<"value">>,[],[{xmlcdata,<<"13934204912325396107">>}]}]}]}]}]}
16:53:58.316 [debug] local route
        from {jid,<<>>,<<"flash.intellin.ru">>,<<>>,<<>>,<<"flash.intellin.ru">>,<<>>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        packet {xmlel,<<"iq">>,[{<<"id">>,<<"ru.i"...>>},{<<"type">>,<<...>>}],[{xmlel,<<...>>,...}]}
16:53:58.317 [debug] session manager
        from {jid,<<>>,<<"flash.intellin.ru">>,<<>>,<<>>,<<"flash.intellin.ru">>,<<>>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>,<<"test">>,<<"flash.intellin.ru">>,<<"chatsecure27345">>}
        packet {xmlel,<<"iq">>,[{<<"id">>,<<"ru.i"...>>},{<<"type">>,<<...>>}],[{xmlel,<<...>>,...}]}
16:53:58.317 [debug] sending to process <0.559.0>
16:53:58.317 [debug] Send XML on stream = <<"<iq from='flash.intellin.ru' to='test@flash.intellin.ru/chatsecure27345' id='ru.intellin.hotline.intellin' type='result'><command xmlns='http://jabber.org/protocol/commands' sessionid='2016-08-02T13:53:58.316143Z' node='register-push-apns' status='completed'><x xmlns='jabber:x:data' type='result'><field var='jid'><value>pubsub.flash.intellin.ru</value></field><field var='node'><value>10999554424259493740</value></field><field var='secret'><value>13934204912325396107</value></field></x></command></iq>">>

In mnesia we have:

mnesia:dirty_select(push_user, [{'_',[],['$_']}]).
[{push_user,{<<"test">>,<<"flash.intellin.ru">>},
            [{subscription,<<"chatsecure27345">>,false,
                           <<"D9AAAC89-624B-4111-84E5-AB803696EA19">>,
                           {local_reg,<<"pubsub.flash.intellin.ru">>,undefined}}],
            [{'include-senders',true},
             {'include-message-count',true},
             {'include-subscription-count',true},
             {'include-message-bodies',false}],
            []}]

mnesia:dirty_select(push_registration, [{'_',[],['$_']}]).
 {push_registration,<<"10999554424259493740">>,
                    {<<"test">>,<<"flash.intellin.ru">>},
                    <<"chatsecure27345">>,<<"Home">>,
                    <<219,79,125,229,205,156,231,103,186,119,190,181,215,94,
                      29,127,205,251,229,167,245,...>>,
                    <<"11746962566654245423">>,<<>>,38321730,
                    {1470,146599,438332}}]

Then i close ios application. Ejabberd log:

17:05:58.135 [debug] Received XML on stream = <<>>
17:05:58.135 [debug] State: {maxrate,1000,956.1566833972819,1470146748526679}, Size=0
M=0.0, I=9608.755
17:05:58.139 [info] Waiting for resumption of stream for test@flash.intellin.ru/chatsecure27345

Then i send the message to test@flash.intellin.ru. Ejabberd log:

17:07:55.975 [debug] Received XML on stream = <<"<message type='chat' id='purplefe26550' to='test@flash.intellin.ru'><active xmlns='http://jabber.org/protocol/chatstates'/><body>erfgewrfgwerqgewrgewrg \t  \t\t\t\t \t \t \t    \t\t  \t   \t\t  \t\t</body></message>">>
17:07:55.976 [debug] route
        from {jid,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"type">>,<<"chat">>},{<<"id">>,<<"purplefe26550">>},{<<"to">>,<<"test@flash.intellin.ru">>}],[{xmlel,<<"active">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/chatstates">>}],[]},{xmlel,<<"body">>,[],[{xmlcdata,<<"erfgewrfgwerqgewrgewrg \t  \t\t\t\t \t \t \t    \t\t  \t   \t\t  \t\t">>}]}]}
17:07:55.976 [debug] local route
        from {jid,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"type">>,<<"chat">>},{<<"id">>,<<...>>},{<<...>>,...}],[{xmlel,<<...>>,...},{xmlel,...}]}
17:07:55.976 [debug] session manager
        from {jid,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"type">>,<<"chat">>},{<<"id">>,<<...>>},{<<...>>,...}],[{xmlel,<<...>>,...},{xmlel,...}]}
17:07:55.976 [debug] sending to process <0.626.0>
17:07:56.017 [debug] Received XML on stream = <<"<message type='chat' id='purplefe26551' to='test@flash.intellin.ru'><active xmlns='http://jabber.org/protocol/chatstates'/></message>">>
17:07:56.018 [debug] route
        from {jid,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"type">>,<<"chat">>},{<<"id">>,<<"purplefe26551">>},{<<"to">>,<<"test@flash.intellin.ru">>}],[{xmlel,<<"active">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/chatstates">>}],[]}]}
17:07:56.018 [debug] local route
        from {jid,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"type">>,<<"chat">>},{<<"id">>,<<...>>},{<<...>>,...}],[{xmlel,<<...>>,...}]}
17:07:56.018 [debug] session manager
        from {jid,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>,<<"admin">>,<<"flash.intellin.ru">>,<<"8775891092885536732579">>}
        to {jid,<<"test">>,<<"flash.intellin.ru">>,<<>>,<<"test">>,<<"flash.intellin.ru">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"type">>,<<"chat">>},{<<"id">>,<<...>>},{<<...>>,...}],[{xmlel,<<...>>,...}]}
17:07:56.018 [debug] sending to process <0.626.0>

Notification is not sent. What I miss? Please need help.

alexsandbox commented 7 years ago

So, I I have to use ejabberd 15.