Git Product home page Git Product logo

ejabberd_mod_gcm's People

Contributors

mrdoctorwho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ejabberd_mod_gcm's Issues

Code cleanup

This module was my first experience with Erlang. Since then I improved my Erlang knowledge a bit, so the module can be improved, too.

Unable to send a message on Ejabberd 16+

server error log:

@ejabberd_hooks:run1:332 {undef,[{xml,get_tag_attr_s,[<<"type">>,{xmlel,<<"message">>,[{<<"xml:lang">>,<<"en">>},{<<"to">>,<<"[email protected]">>},{<<"type">>,<<"chat">>},{<<"id">>,<<"125">>}],[{xmlel,<<"body">>,[],[{xmlcdata,<<"dasd">>}]},{xmlel,<<"thread">>,[],[{xmlcdata,<<"VHTVVQPDlDznyPhoWYrZDLGmDPHqmkZx">>}]}]}],[]},{mod_gcm,message,3,[{file,"src/mod_gcm.erl"},{line,87}]},{ejabberd_hooks,safe_apply,3,[{file,"src/ejabberd_hooks.erl"},{line,382}]},{ejabberd_hooks,run1,3,[{file,"src/ejabberd_hooks.erl"},{line,329}]},{ejabberd_sm,route,3,[{file,"src/ejabberd_sm.erl"},{line,114}]},{ejabberd_local,route,3,[{file,"src/ejabberd_local.erl"},{line,112}]},{ejabberd_router,route,3,[{file,"src/ejabberd_router.erl"},{line,77}]},{ejabberd_c2s,check_privacy_route,5,[{file,"src/ejabberd_c2s.erl"},{line,2113}]}]}

Am not able to register the gcm id to xmpp server.
Sent:
2016-04-22 10:39:39.840 [debug] <0.5349.0>@ejabberd_receiver:process_data:283 Received XML on stream = <<"APA91bGaAKqg9KT1o5JmNG3xuL8l0E37pPtcduRV4_0iTc2-kD0qzl4DoK4MqT2aqZlfa3ced4wxuq1tUhy2IPCD-G07nkX3hT9qVUljteZpmuLoYW5spwJMGZOR8cQGBuWvAxFd55Dn">>

Received:
2016-04-22 10:39:39.843 [error] <0.5350.0>@gen_iq_handler:process_iq:129 {undef,[{xml,get_subtag,[{xmlel,<<"register">>,[{<<"xmlns">>,<<"https://android.googleapis.com/gcm">>}],[{xmlel,<<"key">>,[],[{xmlcdata,<<"APA91bGaAKqg9KT1o5JmNG3xuL8l0E37pPtcduRV4_0iTc2-kD0qzl4DoK4MqT2aqZlfa3ced4wxuq1tUhy2IPCD-G07nkX3hT9qVUljteZpmuLoYW5spwJMGZOR8cQGBuWvAxFd55Dn">>}]}]},<<"key">>],[]},{mod_gcm,iq,3,[{file,"src/mod_gcm.erl"},{line,128}]},{gen_iq_handler,process_iq,6,[{file,"src/gen_iq_handler.erl"},{line,128}]},{ejabberd_local,route,3,[{file,"src/ejabberd_local.erl"},{line,112}]},{ejabberd_router,route,3,[{file,"src/ejabberd_router.erl"},{line,77}]},{ejabberd_c2s,check_privacy_route,5,[{file,"src/ejabberd_c2s.erl"},{line,2113}]},{ejabberd_c2s,session_established2,2,[{file,"src/ejabberd_c2s.erl"},{line,1271}]},{p1_fsm,handle_msg,10,[{file,"src/p1_fsm.erl"},{line,582}]}]}

Can you please help me out in the issue.

Instead of sending use it as a mechanism for connection

Hi, It's a great plugin especially for mobile apps where chances of your service getting killed is very high. It's not useful for offline messages since GCM is based on XMPP and will itself be offline. GCM have even more problems with a very high ping time.

I wanted to see if it can be modified to signal a new message and get the xmpp reconnected. Sending offline messages through GCM have few issue since there is no roster, no jingle support and if used as signaling it will be great.

ejabberd 17.04 Support - Hook offline_message_hook crashed when running mod_gcm:message

2017-05-08 09:50:13.938 [error] <0.484.0>@ejabberd_hooks:safe_apply:383 Hook offline_message_hook crashed when running mod_gcm:message/1:
** Reason = {error,undef,[{mod_gcm,message,[],[{bounce,{message,<<>>,normal,<<"en">>,{jid,<<"cr3397">>,<<"kripter.io">>,<<"mobile">>,<<"cr3397">>,<<"kripter.io">>,<<"mobile">>},{jid,<<"dz9199">>,<<"kripter.io">>,<<>>,<<"dz9199">>,<<"kripter.io">>,<<>>},[],[],undefined,[{xmlel,<<"paused">>,[{<<"xmlns">>,<<"http://jabber.org/protocol/chatstates">>}],[]}],#{ip => {0,0,0,0,0,65535,28806,20552}}}}]},{ejabberd_hooks,safe_apply,[{file,"src/ejabberd_hooks.erl"},{line,380}],4},{ejabberd_hooks,run_fold1,[{file,"src/ejabberd_hooks.erl"},{line,364}],4},{ejabberd_sm,route,[{file,"src/ejabberd_sm.erl"},{line,138}],1},{ejabberd_local,route,[{file,"src/ejabberd_local.erl"},{line,116}],1},{ejabberd_router,do_route,[{file,"src/ejabberd_router.erl"},{line,346}],1},{ejabberd_router,route,[{file,"src/ejabberd_router.erl"},{line,87}],1},{ejabberd_c2s,check_privacy_then_route,[{file,"src/ejabberd_c2s.erl"},{line,770}],2}]}

Problem starting the module mod_gcm for host localhost

Hi Doctor,
I've setup ejabberd in Elixir/Phoenix application. Mix.exs has {:ejabberd, "~> 17.9"}. I've also copied mod_gcm.erl in src folder and put the following entry in ejabberd.yml.

mod_gcm:
gcm_api_key: "key"
While starting the phoenix app application stops with following error:

[warn] module 'mod_gcm' doesn't export mod_opt_type/1
[error] Problem starting the module mod_gcm for host localhost
options: [{gcm_api_key,<<"key">>}]
error: undef
[{mod_gcm,start,
[<<"localhost">>,
[{gcm_api_key,<<"key">>}]],
[]},
{gen_mod,start_module,4,[{file,"src/gen_mod.erl"},{line,200}]},
{lists,foreach,2,[{file,"lists.erl"},{line,1338}]},
{gen_mod,start_link,0,[{file,"src/gen_mod.erl"},{line,79}]},
{supervisor,do_start_child,2,[{file,"supervisor.erl"},{line,365}]},
{supervisor,start_children,3,[{file,"supervisor.erl"},{line,348}]},
{supervisor,init_children,2,[{file,"supervisor.erl"},{line,314}]},
{gen_server,init_it,6,[{file,"gen_server.erl"},{line,328}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]
[error] ejabberd initialization was aborted because a module start failed.

The PUSH is not being send by the module

Hello Doctor, I'm trying to use your mod_gcm (and understand how it works) on Ejabberd 16.03, but i have a problem.
For start..i have added the mod_gcm.erl in the ejabberd/src dir and also the following in the ejabberd.yml file under the MODULES section
mod_gcm: gcm_api_key: gcm_api_key
where the last gcm_api_key is a global variable containing my API KEY (private, based on my Android App).
After the ejabberd reboot seems ok, the log return a row: mod_gcm:start:159 mod_gcm Has start successfully!.
So, as next step i've added to my Android XMPPManager Class the method to send the set iq stanza with the server and token (sender gcm registration id) info. This is what i've sent (Android Studio log):
<iq to='myserveraddr' id='dPqJJ-10' type='set'><register xmlns='https://android.googleapis.com/gcm'><key>f6Es9KFADRQ:APA92bGovzSlDsM3v0vmEaOTbQduDIj2pZbd8TRA_J7fLP_lH1CrhlG-sI62Iyi2L6sNXK0HZAIdFs5F7AUobIVCf4ZVfXxE0tDZek1TNwardz4aa1PbsE8gLzFEx5IQ1MQgdNAymQg-</key></register></iq>
The response seems ok (Android Studio log), no error:
<iq from='myserveraddr' to='1@myserveraddr/f6Es9KFADRQ' id='dPqJJ-10' type='result'/>
(f6Es9KFADRQ is the device name and is ok)

In the Ejabberd log now i can see a row that say that a new user has been registered (1@myserveraddr)... OK!

Done the above "registration" for both the user n.1 and n.2 (with success) i've tried to send a message from user n.1 to the offline user n.2, but on the Ejabberd log i've found the following error:
mod_gcm:message:89 FORMAT ERROR: "Offline message ~s [{jid,<<"1">>,<<"myserveraddr">>,<<"f6Es9KFADRQ">>,<<"1">>,<<"myserveraddr">>,<<"f6Es9KFADRQ">>}]

the offline message was not sent.. what can be the problem?

-- EDIT --

Changing the mod_gcm.erl INFO_MSG log parameter from [From] to [To]:
?INFO_MSG("Offline message ~s", [To]),
i noticed that return the same jid info of the sender (1, myserveraddr, f6Es9KFADRQ), it should be "2"?.. but i don't know how to set it

Unable to use it

Hi Doctor,

I have tried using this module and followed your mentioned steps. I am using Android and my device is nexus 5 with 5.1 OS.

I have declared module in yml like following

mod_gcm:
gcm_api_key: "xxxxxxxxxxxxxxxxxxxxxxxxxx"

and copied .beam file in ebin directory. I am using 15.04 version of Ejabberd.

How I tested:
After login I sent a packet with mentioned format. But and then put the A party on offline mode. Then I tried sending messages from Party B and no push message was received. Can you please help me getting fixed this issue thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.