mrDoctorWho / ejabberd_mod_apns

An ejabberd module to send PUSH messages to iOS devices through APNS
MIT License
33 stars 19 forks source link

Unable to get subscription with mod_shared_roster #8

Closed vijayaa closed 7 years ago

vijayaa commented 8 years ago

module loaded successfully. But not receiving notification.

please find the logs below.

`2016-07-27 11:15:38.141 [debug] <0.6759.0>@ejabberd_receiver:process_data:283 Received XML on stream = <<"<message from=\"+919986790176@chatserver.com/353305061173502\" id=\"f78a318a-fd97-4742-94a0-9c0d8bfe7304\" type=\"chat\" to=\"+918792320908@chatserver.com\"><markable xmlns=\"urn:xmpp:chat-markers:0\"/><body>No</body></message>">>

2016-07-27 11:15:38.141 [debug] <0.6759.0>@shaper:update:120 State: {maxrate,1000,984.9189934146625,1469598287531719}, Size=231
M=227.56804481749498, I=50609.831
2016-07-27 11:15:38.143 [debug] <0.367.0>@ejabberd_odbc:sql_query_internal:474 SQL: "insert into archive (username, timestamp, peer, bare_peer, xml, txt, kind, nick) values ('+919986790176', '1469598338142468', '+918792320908@chatserver.com', '+918792320908@chatserver.com', '<message from=''+919986790176@chatserver.com/353305061173502'' to=''+918792320908@chatserver.com'' xml:lang=''en'' id=''f78a318a-fd97-4742-94a0-9c0d8bfe7304'' type=''chat''><markable xmlns=''urn:xmpp:chat-markers:0''/><body>No</body></message>', 'No', 'chat', '');"

2016-07-27 11:15:38.145 [debug] <0.6760.0>@ejabberd_router:do_route:324 route
        from {jid,<<"+919986790176">>,<<"chatserver.com">>,<<"353305061173502">>,<<"+919986790176">>,<<"chatserver.com">>,<<"353305061173502">>}
        to {jid,<<"+918792320908">>,<<"chatserver.com">>,<<>>,<<"+918792320908">>,<<"chatserver.com">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"from">>,<<"+919986790176@chatserver.com/353305061173502">>},{<<"id">>,<<"f78a318a-fd97-4742-94a0-9c0d8bfe7304">>},{<<"type">>,<<"chat">>},{<<"to">>,<<"+918792320908@chatserver.com">>}],[{xmlel,<<"markable">>,[{<<"xmlns">>,<<"urn:xmpp:chat-markers:0">>}],[]},{xmlel,<<"body">>,[],[{xmlcdata,<<"No">>}]}]}
2016-07-27 11:15:38.145 [debug] <0.6760.0>@ejabberd_local:do_route:260 local route
        from {jid,<<"+919986790176">>,<<"chatserver.com">>,<<"353305061173502">>,<<"+919986790176">>,<<"chatserver.com">>,<<"353305061173502">>}
        to {jid,<<"+918792320908">>,<<"chatserver.com">>,<<>>,<<"+918792320908">>,<<"chatserver.com">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"from">>,<<...>>},{<<...>>,...},{...}|...],[{xmlel,<<...>>,...},{xmlel,...}]}

2016-07-27 11:15:38.145 [debug] <0.6760.0>@ejabberd_sm:do_route:419 session manager
        from {jid,<<"+919986790176">>,<<"chatserver.com">>,<<"353305061173502">>,<<"+919986790176">>,<<"chatserver.com">>,<<"353305061173502">>}
        to {jid,<<"+918792320908">>,<<"chatserver.com">>,<<>>,<<"+918792320908">>,<<"chatserver.com">>,<<>>}
        packet {xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"from">>,<<...>>},{<<...>>,...},{...}|...],[{xmlel,<<...>>,...},{xmlel,...}]}

2016-07-27 11:15:38.146 [debug] <0.367.0>@ejabberd_odbc:sql_query_internal:474 SQL: "select password from users where username='+918792320908';"
2016-07-27 11:15:38.147 [debug] <0.6760.0>@mod_apns:message:79 Offline message````
mrDoctorWho commented 8 years ago

@vijayaa The log you provided lacks the mod_apns parts.

vijayaa commented 8 years ago

these logs are related to message. 918792320908@chatserver.com user is offline and registered for apns

mrDoctorWho commented 8 years ago

@vijayaa They are, but I can't tell you anything until I see the mod_apns logs.

vijayaa commented 8 years ago

i could see only one log @mod_apns:message:79 Offline message`

mrDoctorWho commented 8 years ago

Did you register the user in the ejabberd database by sending the stanza mentioned in the README?

vijayaa commented 8 years ago

Yes. And below are the mnesia contents of that user {apns_users,{<<"+918792320908">>, <<"chatserver.com">>}, <<"507e597290473dac2aa280b92e41517ec38c812ad29c6fe75259f95e1449d9e6">>, 1469599543}

We have enabled archive module also. Does this give any issue

mrDoctorWho commented 8 years ago

Do the users have subscription BOTH?

vijayaa commented 8 years ago

Yes. Subscription both

mrDoctorWho commented 8 years ago

@vijayaa look if the user registered and message arrives to the module handler, then I see no reason why no further logs appear.

Check out this debug version of the module https://gist.github.com/mrDoctorWho/b3a4bff3b732b49463c3c5ec489f5d11 . It has ?DEBUG() calls everywhere, so you must see what's going on in the logs.

vijayaa commented 8 years ago

i think the issue is we are using shared roaster group. ejabberd doesn't store the subscription details in rosterusers. i added debugs after this line {Subscription, _Groups} = ejabberd_hooks:run_fold(roster_get_jid_info, ToServer, {none, []}, [ToUser, ToServer, From]); This is returning empty

mrDoctorWho commented 8 years ago

@vijayaa What module currently provides shared roster groups? I'm not currently watching ejabberd development.

vijayaa commented 8 years ago

mod_shared_roster module. Our requirement is all users under one virtual host should be contacts to each other. so we have used this module

mrDoctorWho commented 8 years ago

@vijayaa I will look what I can do around this

vijayaa commented 8 years ago

can i comment this subscription. will it give any issue

mrDoctorWho commented 8 years ago

@vijayaa Of course you can

vijayaa commented 8 years ago

can you please help me in this. i don't know much of erlnag

mrDoctorWho commented 8 years ago

Well, the fastest way for you is to change:

{Subscription, _Groups} = 
    ejabberd_hooks:run_fold(roster_get_jid_info, ToServer, {none, []}, [ToUser, ToServer, From]),

to this:

Subscription = both,

Make sure you have comma at the end of the line.

vijayaa commented 8 years ago

Thank you

vijayaa commented 8 years ago

it is trying to send PUSH. But notification not received on the phone. Logs are below. I am using VOIP certificate 2016-07-28 14:03:26.492 [debug] <0.10441.0>@mod_apns:message:79 Offline message 2016-07-28 14:03:26.492 [debug] <0.10441.0>@mod_apns:message:109 mod_apns: Record found, sending the PUSH 2016-07-28 14:03:26.492 [debug] <0.10441.0>@mod_apns:send_payload:30 FORMAT ERROR: "mod_apns: trying to send payload with these parameters: Address: ~s Port: ~s Cert: ~s Keyfile: ~s Password ~s" ["gateway.sandbox.push.apple.com",2195,""/home/ejabberd/config/VoIP_Cert.pem","/home/ejabberd/config/VoIP_Key.pem","teledna"]

2016-07-28 14:03:28.260 [debug] <0.10441.0>@mod_apns:send_payload:55 mod_apns: Successfully sent payload to the APNS server

mrDoctorWho commented 8 years ago

@vijayaa please ensure that the problem is not on the client (phone) side. Find some kind of a service or something that will allow you to test PUSH notifications with your phone and given credentials.

vijayaa commented 8 years ago

Log shows 30 FORMAT ERROR: is there any issue with that

mrDoctorWho commented 8 years ago

@vijayaa FORMAT ERRORs have nothing to do with it. The module reports that the payload was sent, so whether a wrong payload was sent or something went wrong on the phone.

vijayaa commented 8 years ago

OK i will check

vijayaa commented 8 years ago

normal push is working. voip push is not working. Thanks for your help

mrDoctorWho commented 8 years ago

@vijayaa Wait, it works with shared roster without any changes in code?

vijayaa commented 8 years ago

Thank you.

mrDoctorWho commented 8 years ago

@vijayaa No-no-no, please answer the question: does it work with mod_shared_roster without any changes in code? Voip push is another issue.

vijayaa commented 8 years ago

No. it did not work.i have commented the {Subscription, _Groups} = ejabberd_hooks:run_fold(roster_get_jid_info, ToServer, {none, []}, [ToUser, ToServer, From]), .. As you mentioned.

vijayaa commented 8 years ago

@mrDoctorWho Are you planning to add support for VOIP Push.

mrDoctorWho commented 8 years ago

@vijayaa I don't think so.

mrDoctorWho commented 7 years ago

Closing due to inactivity

BesatZardosht commented 7 years ago

Why is it checking the subscription? I think it still makes sense to send apns even if subscription is not both.

mrDoctorWho commented 7 years ago

@BesatZardosht that was made to prevent spams.

BesatZardosht commented 7 years ago

Thanks for explanation!