2

I am in the process of configuring the ejabber server for one of our project.In this we need to configure the mod_rest module (https://github.com/processone/ejabberd-contrib) from ejabberd-contrib. Below are my configuration (YAML) in listen

 port: 5280
    module: ejabberd_http
    request_handlers:
      "/rest": mod_rest
    web_admin: true
    http_poll: true
    http_bind: true
    ## register: true
    captcha: true


modules:
  mod_rest:
    allowed_ips:
      - "host_one_ip"
      - "host_one_ip"
    access_commands:
      - "registered_users"
      - "connected_users"
    allowed_destinations:
      - "all"

But whenever i am trying to hit the ejabberd command using the rest (curl call) its giving me "TryPOSTING Stanza"

    prompt# curl --data 'registered_users domain' -X POST http://host:5280/rest/

Try POSTing a stanza. 

I tried to go though the forum but couldn't find ...anything helpful

I am new to ejabber and erlang. Any pointer in this direction will be very helpful. Please let me know if any more details are required.

sagar27
  • 2,433
  • 3
  • 22
  • 35

3 Answers3

2

Guys i have figured out the issue for this. I have installed Ejabberd 14.05 version. The mod_rest module was including the ejabberd_http.hrl file for its dev_include directories.In the Ejabberd 14.05 the record for ejabberd_http.hrl are changed. "opts = [] :: list()," is an extra header in the ejabber-contrib`s include folder. I adjusted the header location accordingly and compile the module. It worked for me :) with this i got the ejabberd commands working using the mod_rest. Now my i facing problem to consumes Stanzas using mod_rest :(. If anyone have any thoughts on the same please let me know.

sagar27
  • 2,433
  • 3
  • 22
  • 35
  • Can you share your code/changes? Here would be a good place: https://github.com/processone/ejabberd-contrib/issues/45 A gist or something else would be fine too. – Christoph Geschwind Dec 12 '14 at 10:32
  • Hey Chris i added my comment there, there is actually no code change just we need to point to proper file :). But now i am facing new issue http://stackoverflow.com/questions/27442324/presence-stanze-for-ejabberd-now-working-via-mod-rest-module – sagar27 Dec 12 '14 at 11:07
  • Hey, I've seen it, very nice, thank you! I will try it out soon. Unfortunately I have no idea regarding your stanza problem, sorry. – Christoph Geschwind Dec 13 '14 at 18:19
0

I try this, and worked:

In my case I use ejabberd binary installation, and the installation folder in /lib/ejabberd/xxxx

Compile the mod_rest.erl from ejabberd-contrib, here is the reference, https://www.ejabberd.im/ejabberd-contrib

I compiled using this command :

erlc -I /lib/ejabberd/include your_mod_rest_source_file

if success, you will have .beam file, after that copy the mod_rest.beam to ejabberd installation folder

cp ~/ejabberd-contrib/mod_rest/src/mod_rest.beam /lib/ejabberd/ebin/

than configure ejabberd.yml in my case the yml reside in (/etc/ejabberd/ejabberd.yml) like this:

https://github.com/processone/ejabberd-contrib/issues/45#issuecomment-69767670

-1

I think you misunderstand the purpose of the ReST module. From the doc, you are supposed to send XMPP stanza to it: https://github.com/processone/ejabberd-contrib/tree/master/mod_rest

However, you are sending plain text, not XMPP stanza (not even XML).

Mickaël Rémond
  • 8,772
  • 1
  • 20
  • 43
  • Hey Michael, Thanks for the reply but, what i am trying is that i need to get the ejabber command working using the mod_rest module.In the Readme given they have mentioned it how it should work. – sagar27 Dec 03 '14 at 06:35
  • EXAMPLE AUTH COMMAND WITH WGET ============================== To execute an ejabberd command, simply provide its name and arguments as in ejabberdctl: wget http://localhost:5280/rest/ --server-response --post-data 'registered_users localhost' If you configure access_commands option, you must provide the credentials like this: wget http://localhost:5280/rest/ --server-response --post-data '--auth user1 localhost thepass registered_users localhost' – sagar27 Dec 03 '14 at 06:36
  • I do not think it works by just passing the ejabberdctl command to rest API. You have to pass them as ReST parameters. – Mickaël Rémond Dec 03 '14 at 12:03
  • POSTing a Stanza doesn't work either. POSTing the ejabberdctl command to mod_rest should work, too. – Christoph Geschwind Dec 03 '14 at 15:15
  • can you please let me know the parameter name, as in the readme file at github they have not mentioned it :( – sagar27 Dec 03 '14 at 17:48