ejabberd - Comments for "Adding user using mod_rest and by sending iq" https://www.ejabberd.im/node/4336 en meblabs wrote: is there any https://www.ejabberd.im/node/4336#comment-61325 <div class="quote-msg"> <div class="quote-author"><em>meblabs</em> wrote:</div> <p>is there any way to receive the stanza result from mod_rest?</p> <p>is this an easy modify? or we can't because of an async process of stanzas... ?</p></div> <p>Not implemented, and it seems difficult to implement.</p> <div class="quote-msg"> <div class="quote-author"><em>meblabs</em> wrote:</div> <p>another question:<br /> is there a way to send 2 or more stanzas to mod_rest without open another connection?<br /> A single mod_rest request takes 1 msec with PHP, if i have to do 10 request it takes too much for a realtime purpose... maybe that with only 1 connection and many stanzas it will be faster.</p></div> <p>It would be nice, but it is'nt immediately implementable, either.</p> Mon, 26 Aug 2013 15:41:05 +0000 mfoss comment 61325 at https://www.ejabberd.im Hi Badlop, is there any way https://www.ejabberd.im/node/4336#comment-61259 <p>Hi Badlop,</p> <p>is there any way to receive the stanza result from mod_rest?</p> <p>is this an easy modify? or we can't because of an async process of stanzas... ?</p> <p>another question:<br /> is there a way to send 2 or more stanzas to mod_rest without open another connection?<br /> A single mod_rest request takes 1 msec with PHP, if i have to do 10 request it takes too much for a realtime purpose... maybe that with only 1 connection and many stanzas it will be faster.</p> <p>thanks</p> <p>PS:<br /> i know about xmlrpc but mod_rest is more efficent and i have to handle pubsub</p> Sun, 18 Aug 2013 18:13:57 +0000 meblabs comment 61259 at https://www.ejabberd.im No idea, just some tests https://www.ejabberd.im/node/4336#comment-56770 <p>Make sure you don't have any error message when ejabberd starts.</p> <p>I configure loglevel to 5, and perform those tests in the same machine that has ejabberd installed.</p> <pre> $ cd ejabberd/src $ erl Erlang R13B04 (erts-5.7.5) [source] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false] Eshell V5.7.5 (abort with ^G) 1&gt; xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, user_resources, [{struct, [{user, "testuser"}, {host, "localhost"}]}]}). {ok,{response,[{struct,[{resources,{array,[]}}]}]}} 2&gt; xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, user_resourcessssssss, [{struct, [{user, "testuser"}, {host, "localhost"}]}]}). {ok,{response,{fault,-112, "Error -112\nUnknown call: {call,user_resourcessssssss,\n [{struct,[{user,\"testuser\"},{host,\"localhost\"}]}]}"}}} 3&gt; xmlrpc:call({127, 0, 0, 1}, 6666, "/", {call, user_resources, [{struct, [{user, "testuser"}, {host, "localhost"}]}]}). {error,econnrefused} </pre><p> ejabberd.log only shows those messages, for command 1 and 2:</p> <pre> (ejabberd@localhost)1&gt; =INFO REPORT==== 28-Oct-2010::00:01:51 === D(&lt;0.399.0&gt;:ejabberd_commands:314) : Executing command ejabberd_sm:user_resources with Args=["testuser", "localhost"] =WARNING REPORT==== 28-Oct-2010::00:03:37 === W(&lt;0.401.0&gt;:ejabberd_xmlrpc:328) : Error -112 Unknown call: {call,user_resourcessssssss, [{struct,[{user,"testuser"},{host,"localhost"}]}]} </pre><p> Then I try:</p> <pre> $ telnet 127.0.0.1 4560 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. aaaaaaaaa HTTP/1.1 400 Bad Request Content-Length: 0 Server: Erlang/1.13 Content-Type: text/xml Connection closed by foreign host. </pre><p> And ejabberd.log shows:</p> <pre> =ERROR REPORT==== 28-Oct-2010::00:08:03 === {tcp_serv,139,{xmlrpc_http,handler,timeout}} </pre> Wed, 27 Oct 2010 22:10:00 +0000 mfoss comment 56770 at https://www.ejabberd.im Hi Again! https://www.ejabberd.im/node/4336#comment-56760 <p>Hi Badlop,<br /> thanks for your prompt response, i took you advice in consideration, and i installed ejabberd_xmlrpc with all its dependences, and i checked that am listening on the port 4560, but each time i submit a request i get the following:</p> <p>=ERROR REPORT==== 2010-10-26 07:41:10 ===<br /> {tcp_serv,139,{xmlrpc_http,handler,timeout}}</p> <p>i checked my configurations and its all okay, i looked into the community but haven't found anyone in my case, how can i know if am sending the right command?<br /> i tried sending many commands like:</p> <p>xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, user_resources, [{struct, [{user, "testuser"}, {host, "localhost"}]}]}).</p> <p>but i get the same result, the connection is not even accepted in the log.</p> Tue, 26 Oct 2010 08:03:44 +0000 nouralk comment 56760 at https://www.ejabberd.im Re: https://www.ejabberd.im/node/4336#comment-56720 <div class="quote-msg"> <div class="quote-author"><em>nouralk</em> wrote:</div> <p>when i already iq stanze sent to <noindex><a href="http://chat.mydomain.com:5280/rest" title="http://chat.mydomain.com:5280/rest" rel="nofollow" >http://chat.mydomain.com:5280/rest</a></noindex> to register and unregister users... but </p> <p>i send an iq to get all users and i can see in the log that it listed all my registered users jid's but how can i use them? can't i receive them in xml format? or as a response for the request? </p></div> <p>mod_rest can send XMPP stanzas, but not receive them.</p> <p>mod_rest can execute commands, receive a response and show it in the shell.</p> <p>Another way to execute ejabberd commands and receive responses in your Python program is to install ejabberd_xmlrpc listener, and make XMLRPC calls instead of REST calls.</p> <div class="quote-msg"> <div class="quote-author"><em>nouralk</em> wrote:</div> <p>using a command in the format:</p> <p>register user domain password<br /> registered_users ....</p> <p>Such commands give me this error...</p> <p>My configurations for modules are as follwoing : </p></div> <p>With that configuration, those commands work for me correctly.</p> <p>Try to update mod_rest of SVN. I added some more detailed error reports, maybe they clarify what is your problem.</p> Mon, 11 Oct 2010 10:19:52 +0000 mfoss comment 56720 at https://www.ejabberd.im My configurations are https://www.ejabberd.im/node/4336#comment-56710 <p>i do have it active, and when i already iq stanze sent to <noindex><a href="http://chat.mydomain.com:5280/rest" title="http://chat.mydomain.com:5280/rest" rel="nofollow" >http://chat.mydomain.com:5280/rest</a></noindex> to register and unregister users... but using a command in the format:</p> <p>register user domain password<br /> registered_users ....</p> <p>Such commands give me this error...</p> <p>My configurations for modules are as follwoing :</p> <p>{modules,<br /> [<br /> {mod_adhoc, []},<br /> {mod_announce, [{access, announce}]}, % requires mod_adhoc<br /> {mod_caps, []},<br /> {mod_configure,[]}, % requires mod_adhoc<br /> {mod_disco, []},<br /> %%{mod_echo, [{host, "echo.im.bayt.com"}]},<br /> {mod_http_bind,[]},<br /> {mod_http_fileserver, [<br /> {docroot, "/var/www"},<br /> {accesslog, "/opt/ejabberd-2.0.0/var/log/ejabberd/access.log"}<br /> ]},<br /> {mod_irc, []},<br /> {mod_last_odbc, []},<br /> {mod_muc, [<br /> %%{host, "conference.@HOST@"},<br /> {access, muc},<br /> {access_create, muc_create},<br /> {access_persistent, muc_create},<br /> {access_admin, muc_admin}<br /> ]},<br /> %%{mod_muc_log,[]},<br /> {mod_offline_odbc, []},<br /> {mod_privacy_odbc, []},<br /> {mod_private_odbc, []},<br /> %%{mod_proxy65,[]},<br /> {mod_pubsub_odbc, [ % requires mod_caps<br /> {access_createnode, pubsub_createnode},<br /> {ignore_pep_from_offline, true},<br /> {last_item_cache, false},<br /> {plugins, ["flat_odbc", "hometree_odbc", "pep_odbc"]}<br /> ]},<br /> {mod_register, [<br /> %%<br /> %% After successful registration, the user receives<br /> %% a message with this subject and body.<br /> %%<br /> {welcome_message, {"Welcome!",<br /> "Welcome to this Jabber server."}},</p> <p> %%<br /> %% When a user registers, send a notification to<br /> %% these Jabber accounts.<br /> %%<br /> %%{registration_watchers, ["admin1@example.org"]},<br /> {registration_timeout, infinity},<br /> {access, register}<br /> ]},<br /> {mod_roster_odbc,[]},<br /> %%{mod_service_log,[]},<br /> {mod_shared_roster,[]},<br /> %%{mod_stats,[]},<br /> {mod_time,[]},<br /> {mod_vcard_odbc,[{search, false}]},<br /> {mod_version,[]},<br /> {mod_rest, [<br /> {allowed_ips, [ {127,0,0,1}]}<br /> ]}<br /> ]}.</p> <p>I need help in my second question please.. how can i receive all the users registered to my server? i send an iq to get all users and i can see in the log that it listed all my registered users jid's but how can i use them? can't i receive them in xml format? or as a response for the request? </p> <p>Thanks for your awesome fast reply :)</p> Wed, 06 Oct 2010 12:09:21 +0000 nouralk comment 56710 at https://www.ejabberd.im mod_rest not running https://www.ejabberd.im/node/4336#comment-56709 <div class="quote-msg"> <div class="quote-author"><em>nouralk</em> wrote:</div> <p>=INFO REPORT==== 2010-10-05 14:15:22 ===<br /> D(&lt;0.370.0&gt;:mod_rest:58) : Error when processing REST request:<br /> Data: "registered_users chat.mydomain.com"<br /> Error: {badmatch,false} </p></div> <p>That strange error report probably indicates that you don't have mod_rest running in the vhost chat.mydomain.com.</p> <p>You must have something like this in your ejabberd.cfg</p> <pre> {modules, [ {mod_rest, []}, ... ]}. </pre><p> Go to ejabberd Web Admin -&gt; Nodes -&gt; your node -&gt; Vhosts -&gt; chat.mydomain.com -&gt; Modules -&gt; check that mod_rest is mentioned in that list.</p> Wed, 06 Oct 2010 10:48:53 +0000 mfoss comment 56709 at https://www.ejabberd.im I am a newbie to ejabberd.. https://www.ejabberd.im/node/4336#comment-56705 <p>I removed all the restrictions from mod_rest configurations,<br /> Sent : "registered_users chat.mydomain.com"</p> <p>still i get the following in log :<br /> =INFO REPORT==== 2010-10-05 14:15:22 ===<br /> I(&lt;0.355.0&gt;:ejabberd_listener:232) : (#Port&lt;0.443&gt;) Accepted connection {{my,ip_address,here},34149} -&gt; {{my,server,ip,here},5280}</p> <p>=INFO REPORT==== 2010-10-05 14:15:22 ===<br /> D(&lt;0.370.0&gt;:ejabberd_http:135) : S: [{["web"],mod_http_fileserver},<br /> {["rest"],mod_rest},<br /> {["admin"],ejabberd_web_admin},<br /> {["http-bind"],mod_http_bind},<br /> {["http-poll"],ejabberd_http_poll}]</p> <p>=INFO REPORT==== 2010-10-05 14:15:22 ===<br /> I(&lt;0.370.0&gt;:ejabberd_http:137) : started: {gen_tcp,#Port&lt;0.443&gt;}</p> <p>=INFO REPORT==== 2010-10-05 14:15:22 ===<br /> D(&lt;0.370.0&gt;:ejabberd_http:254) : (#Port&lt;0.443&gt;) http query: 'POST' /rest</p> <p>=INFO REPORT==== 2010-10-05 14:15:22 ===<br /> D(&lt;0.370.0&gt;:ejabberd_http:420) : client data: "registered_users chat.mydomain.com"</p> <p>=INFO REPORT==== 2010-10-05 14:15:22 ===<br /> D(&lt;0.370.0&gt;:ejabberd_http:323) : ["rest"] matches ["rest"]</p> <p>=INFO REPORT==== 2010-10-05 14:15:22 ===<br /> I(&lt;0.370.0&gt;:mod_rest:92) : Data: "registered_users chat.mydomain.com"</p> <p>=INFO REPORT==== 2010-10-05 14:15:22 ===<br /> D(&lt;0.370.0&gt;:mod_rest:58) : Error when processing REST request:<br /> Data: "registered_users chat.mydomain.com"<br /> Error: {badmatch,false} </p> <p>Another thing i need to verify, i read that i can query for all online users, so i send the following command:</p> <p>i can see that the command is parsed and executed correctly, but how can i use this info? i mean i am supposed to receive it somewhere in the response , right? because i dont get anything except "OK", can i get it as xml? or response? or anything i can parse and use?</p> <p>Thanks a lot!</p> Tue, 05 Oct 2010 14:45:51 +0000 nouralk comment 56705 at https://www.ejabberd.im Try a simple module https://www.ejabberd.im/node/4336#comment-56695 <p>Try a simple module configuration, without access restrictions:</p> <pre> {mod_rest, []}, </pre><p> Execute a simple call, for example this python file:</p> <pre> import urllib2 server_url = 'http://localhost:5280/rest/' call = 'register user1 localhost pass123' resp = urllib2.urlopen(server_url, call) result = resp.read() print result </pre><p> Execute it and you should get a valid response, and the account is registered</p> <pre> $ python aa.py User user1@localhost successfully registered $ ejabberdctl registered_users localhost admin user1 </pre><p> Once this simple configuration works, you can try to configure the access option and provide the access parameter in the call.</p> Sun, 03 Oct 2010 21:26:54 +0000 mfoss comment 56695 at https://www.ejabberd.im