I am using ejabberd community server version 17.04 on Ubuntu 14.04
My question is how to send message from ejabberd server to multiple clients. I was able to send message to a single client using the command:
ejabberdctl send_message chat 192.168.33.50 user1@192.168.33.50 "subject" "message from server"
(where 192.168.33.50 is the IP address of the machine running ejabberd)
However, I could not find a way to send to multiple clients at once.
I suppose the method would be to create a group, add users to the group and send message to the group.
I tried to the following commands to create a group and add users to it:
ejabberdctl srg_create group1 192.168.33.50 "group1" "group1" "group1"
ejabberdctl srg_user_add user1 192.168.33.50 group1 192.168.33.50
ejabberdctl srg_user_add user2 192.168.33.50 group1 192.168.33.50
However, when I tried sending message with the following command using the group name instead of user name, no message was sent from the server:
ejabberdctl send_message chat 192.168.33.50 group1@192.168.33.50 "subject" "message from server"
So I wanted to know how I can achieve my use case of sending messages to multiple clients from the ejabberd server?
The Shared Roster Group
The Shared Roster Group feature is designed for sharing roster contacts and presence, not messages. It seems a cool idea, by the way.
I can think three ways:
A) If you want to send to all the accounts in the server, use mod_announce
B) If you just want to send to a specific list of users, they should have joined a MUC room, then you can send a message to that room, and the server delivers the message to all the room occupants.
C) If you enable mod_multicast, you can send the message to the multicast service and provide the multiple destinations as CC, seehttps://xmpp.org/extensions/xep-0033.html
Thanks for the response. I am
Thanks for the response.
I am just starting out on ejabberd and have a few more questions.
1) How exactly do I use the methods A) and C) ( that is mod_annouce and mod_multicast). I have the following lines in my ejabberd config file (ejabberd.yml) under the heading "modules:"
mod_announce: # recommends mod_adhoc
access: announce
and
mod_multicast: {} ( this was commented earlier, I uncommented and restarted the server).
Is that all that is required to enable these two modules?
2)Once these modules are enabled, what command/method can I use to actually send message to all users(in case of mod_announce) or to multiple users(in case of mod_multicast). Meaning my question basically is what is the equivalent of ejabberdctl send_message for multiple users. I had a look at all the options of ejabberdctl and could not find anything.
3) My use case is basically to send push notifications to clients using ejabberd. So I may need to send notifications to either one, many or all devices and therefore I don't think I can use the approach B since the server would decide which clients to send to, the clients won't know before hand and therefore they cannot join MUC room .
1. Yes, that is enough. 2.A)
1. Yes, that is enough.
2.A) Send XMPP messages to specific XMPP addresses, see https://docs.ejabberd.im/admin/configuration/#mod-announce
2.B) Send XMPP messages to the new multicast service, with some additional TO, CC, BCC elements, see example messages inhttps://xmpp.org/extensions/xep-0033.html
First try all this using an XMPP client. If you are happy with the results, then you can investigate how to perform those tasks with ejabberdctl programatically. I imagine "ejabberdctl send_message" will work.
sinha.archit wrote: I was
I was able to send message to a single client using the command:
ejabberdctl send_message chat 192.168.33.50 user1@192.168.33.50 "subject" "message from server"
(where 192.168.33.50 is the IP address of the machine running ejabberd)
hi sinha.archit. i have a problem to use the "send_message" command on my ejabberd server. When i use the command, it return nothing. The receiver did not receive any message from admin. May i know how u did that? is it any configuration needed?