ndl / mod_archive2

mod_archive2 is new ejabberd module implementing server-side instant messaging history support specified in XEP-136.
http://www.ndl.kiev.ua/content/modarchive2
27 stars 5 forks source link

How to config with mod_archive2 ? #8

Open huyd opened 10 years ago

huyd commented 10 years ago

Hi ndl,

I'm working on ejabberd, i want to save archive message with full message stanza.. I found a solution that install mod_archive2. But i can't find any configuration example. This is my ejabberd.cfg:

{mod_archive2, [{database_type, "mysql"},
                      {default_auto_save, "message"},
                      {read_only, false},
                      {default_expire, infinity},
                      {enforce_min_expire, 0},
                      {enforce_max_expire, infinity},
                      {replication_expire, 31536000},
                      {session_duration, 1800},
                      {wipeout_interval, 86400},
                      {prefs_cache_interval, 86400}]}

But service return this error below:

<body xmlns="http://jabber.org/protocol/httpbind">
   <iq xmlns="jabber:client" from="52d3f1b237b9d2740d73fcaa@192.168.2.91" to="52d3f1b237b9d2740d73fcaa@192.168.2.91/webchat-5830" type="error" id="4881:sendIQ">
      <pref xmlns="http://www.xmpp.org/extensions/xep-0136.html#ns" />
      <error code="503" type="cancel">
         <service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" />
      </error>
   </iq>
   <presence xmlns="jabber:client" from="52d3f1b237b9d2740d73fcaa@192.168.2.91/webchat-5830" to="52d3f1b237b9d2740d73fcaa@192.168.2.91/webchat-5830" />
</body>

Please help config my ejabberd server to use mod_archive2. Thank you so much

nobelium commented 10 years ago

Hi @ndl, even I'm stuck with config for mod_archive2. I have just add mod_archive2 (no other options) to the ejabberd config file and upon query for services via Strophe $iq({type: "get", id:"version2", to: @domain}).c("query", {xmlns: "http://jabber.org/protocol/disco#info"})

I'm getting this

"<feature xmlns="http://jabber.org/protocol/disco#info" var="urn:xmpp:archive:manual"/>"
"<feature xmlns="http://jabber.org/protocol/disco#info" var="urn:xmpp:archive:manage"/>"
"<feature xmlns="http://jabber.org/protocol/disco#info" var="urn:xmpp:archive:auto"/>"
"<feature xmlns="http://jabber.org/protocol/disco#info" var="urn:xmpp:archive:pref"/>"

But I don't see any messages stored on the MySQL database. I have configured mysql database for all other services like offline, pubsub, roster and they are working fine.

Any help would be greatly appreciated.

ndl commented 10 years ago

Here's an example of my working config:

  {mod_archive2, [{rdbms, pgsql},
                  {time_accuracy, milliseconds},
                  {default_auto_save, body},
                  {only_in_roster, true},
                  {force_utc, true},
                  {enforce_default_auto_save, false},
                  {default_expire, infinity},
                  {enforce_min_expire, 0},
                  {enforce_max_expire, infinity},
                  {replication_expire, 31536000},
                  {session_duration, 1800},
                  {wipeout_interval, 86400},
                  {prefs_cache_interval, 1800}]},

Please note the lack of quotes in 'rdbms' and 'default_auto_save' parameters.

'message' save method and 'mysql' rdbms type should also work - provided you specify these correctly, i.e. without quotes.

If you still get errors, I'll need the following information to diagnose them:

  1. Exact ejabberd version you're using.
  2. Extract from the ejabberd logs that contains the error: typically 5xx error types will leave stack trace in the log file.
huyd commented 10 years ago

hi ndl,

I have tried your solution but still get error "service-unavailable" above. I used ejabberd-2.1.13 and Erlang R14B04 My ejabberd.conf:

{mod_archive2, [{rdbms, mysql},
                  {time_accuracy, milliseconds},
                  {default_auto_save, message},
                  {only_in_roster, true},
                  {force_utc, true},
                  {enforce_default_auto_save, true},
                  {default_expire, infinity},
                  {enforce_min_expire, 0},
                  {enforce_max_expire, infinity},
                  {replication_expire, 31536000},
                  {session_duration, 1800},
                  {wipeout_interval, 86400},
                  {prefs_cache_interval, 1800}]}

Step 1: Run ./make.sh inside mod_archive2 and i got:

quocnguyen@htk:~/ejabberd_mod/mod_archive2$ ./make.sh 
Recompile: src/xmpp_api_ejabberd
Recompile: src/xmpp_api_mock
Recompile: src/mod_archive2_xml
Recompile: src/mod_archive2_utils
Recompile: src/mod_archive2_time
Recompile: src/mod_archive2_storage
Recompile: src/mod_archive2_prefs
Recompile: src/mod_archive2_manual
Recompile: src/mod_archive2_management
Recompile: src/mod_archive2_maintenance
Recompile: src/mod_archive2_auto
Recompile: src/mod_archive2
Recompile: src/dbms_storage_utils
Recompile: src/dbms_storage_odbc
Recompile: src/dbms_storage_mnesia
Recompile: src/dbms_storage
Recompile: test/unit/testing
test/testing.hrl:26: can't find include file "config.hrl"

Step 2: move all beam file to ../lib/ejabberd-2.1.13/ebin Step 3: Start ejabberd server After started, i check my ejabberd.log and it's empty. My stanza:

<body xmlns="http://jabber.org/protocol/httpbind" rid="9793" sid="c79a1873a740aee4a3d504dd415470247756c266">
   <iq xmlns="jabber:client" type="get" id="5024:sendIQ">
      <pref xmlns="http://www.xmpp.org/extensions/xep-0136.html#ns" />
   </iq>
   <presence xmlns="jabber:client" />
</body>

But when i send stanza get config mod_archive i have got this error in ejabberd.log:

=ERROR REPORT==== 2014-02-08 09:39:18 ===
E(<0.351.0>:mod_pubsub_odbc:3682) : transaction return internal error: {aborted,
                                                                        {undef,
                                                                         [{node_flat,
                                                                           get_entity_subscriptions_for_send_last,
                                                                           ["pubsub.192.168.2.91",
                                                                            {jid,
                                                                             "52d3f1b237b9d2740d73fcaa",
                                                                             "192.168.2.91",
                                                                             "webchat-6683",
                                                                             "52d3f1b237b9d2740d73fcaa",
                                                                             "192.168.2.91",
                                                                             "webchat-6683"}]},
                                                                          {mod_pubsub_odbc,
                                                                           node_call,
                                                                           3},
                                                                          {ejabberd_odbc,
                                                                           execute_bloc,
                                                                           1},
                                                                          {ejabberd_odbc,
                                                                           run_sql_cmd,
                                                                           4},
                                                                          {p1_fsm,
                                                                           handle_msg,
                                                                           10},
                                                                          {proc_lib,
                                                                           init_p_do_apply,
                                                                           3}]}}

=ERROR REPORT==== 2014-02-08 09:39:18 ===
E(<0.351.0>:mod_pubsub_odbc:3682) : transaction return internal error: {aborted,
                                                                        {undef,
                                                                         [{node_hometree,
                                                                           get_entity_subscriptions_for_send_last,
                                                                           ["pubsub.192.168.2.91",
                                                                            {jid,
                                                                             "52d3f1b237b9d2740d73fcaa",
                                                                             "192.168.2.91",
                                                                             "webchat-6683",
                                                                             "52d3f1b237b9d2740d73fcaa",
                                                                             "192.168.2.91",
                                                                             "webchat-6683"}]},
                                                                          {mod_pubsub_odbc,
                                                                           node_call,
                                                                           3},
                                                                          {ejabberd_odbc,
                                                                           execute_bloc,
                                                                           1},
                                                                          {ejabberd_odbc,
                                                                           run_sql_cmd,
                                                                           4},
                                                                          {p1_fsm,
                                                                           handle_msg,
                                                                           10},
                                                                          {proc_lib,
                                                                           init_p_do_apply,
                                                                           3}]}}

=ERROR REPORT==== 2014-02-08 09:39:18 ===
E(<0.351.0>:mod_pubsub_odbc:3682) : transaction return internal error: {aborted,
                                                                        {undef,
                                                                         [{node_pep,
                                                                           get_entity_subscriptions_for_send_last,
                                                                           ["pubsub.192.168.2.91",
                                                                            {jid,
                                                                             "52d3f1b237b9d2740d73fcaa",
                                                                             "192.168.2.91",
                                                                             "webchat-6683",
                                                                             "52d3f1b237b9d2740d73fcaa",
                                                                             "192.168.2.91",
                                                                             "webchat-6683"}]},
                                                                          {mod_pubsub_odbc,
                                                                           node_call,
                                                                           3},
                                                                          {ejabberd_odbc,
                                                                           execute_bloc,
                                                                           1},
                                                                          {ejabberd_odbc,
                                                                           run_sql_cmd,
                                                                           4},
                                                                          {p1_fsm,
                                                                           handle_msg,
                                                                           10},
                                                                          {proc_lib,
                                                                           init_p_do_apply,
                                                                           3}]}}

Please help me to fix it, thanks you so much.

huyd commented 10 years ago

I think that log above don't regarding mod_archive2. I don't know why mod_archive2 don't working. Are my beam files error or odbc server config error?

{odbc_server, {mysql, "localhost", "ejabberd", "root", "root"}}.

i have used mod_archive with odbc server configuration above and it worked.

nobelium commented 10 years ago

Hi @ndl, even I have configured mod_archive2 with the following configuration

{mod_archive2, [{rdbms, mysql},
                  {time_accuracy, milliseconds},
                  {default_auto_save, body},
                  {only_in_roster, true},
                  {force_utc, true},
                  {enforce_default_auto_save, true},
                  {default_expire, infinity},
                  {enforce_min_expire, 0},
                  {enforce_max_expire, infinity},
                  {replication_expire, 31536000},
                  {session_duration, 1800},
                  {wipeout_interval, 86400},
                  {prefs_cache_interval, 1800}]},

I have set enforce_default_auto_save to true and I'm using mysql. When I send a query to check if mod_archive is enabled @conn.send($iq({id:'info1', type: "get"}).c("pref", {xmlns: "urn:xmpp:archive"})) it gives me

<iq xmlns="jabber:client" from="username2@domain" to="username@domain/37232626041391851384543718" id="info1" type="result">
  <pref xmlns="urn:xmpp:archive">
    <default save="body" otr="forbid" unset="true"/>
    <method type="auto" use="prefer"/>
    <method type="local" use="concede"/>
    <method type="manual" use="concede"/>
    <auto save="true" scope="global"/>
  </pref>
</iq> 

but the messages that I send are not being store on the database and if I request for a collection of archives I'm getting a blank list

<iq xmlns="jabber:client" from="username@domain" to="username2@domain/4131061852139185215623896" id="get1" type="result">
  <list xmlns="urn:xmpp:archive"/> 
</iq>

I was getting this error a few days back. But now I'm not getting any errors.

2014-02-05 18:59:17.790 [critical] <0.38.0>@gen_mod:start_module:83 ejabberd initialization was aborted because a module start failed.
2014-02-05 18:59:33.205 [critical] <0.38.0>@gen_mod:start_module:78 Problem starting the module mod_archive2 for host <<"localhost">>
 options: []
 error: badarg
[{erlang,list_to_atom,
         [[100,98,109,115,95,115,116,111,114,97,103,101,95|<<"localhost">>]],
         []},
 {mod_archive2_utils,get_module_proc,2,
                     [{file,"src/mod_archive2_utils.erl"},{line,60}]},
 {dbms_storage,start,2,[{file,"src/dbms_storage.erl"},{line,111}]},
 {mod_archive2,start,2,[{file,"src/mod_archive2.erl"},{line,134}]},
 {gen_mod,start_module,3,[{file,"src/gen_mod.erl"},{line,70}]},
 {lists,foreach,2,[{file,"lists.erl"},{line,1323}]},
 {ejabberd_app,start,2,[{file,"src/ejabberd_app.erl"},{line,67}]},
 {application_master,start_it_old,4,
                     [{file,"application_master.erl"},{line,269}]}]

Please help, thanks for giving a config example.

huyd commented 10 years ago

hi nobelium,

is your mod_archive2 service running ? Can you give me beam files, which were created by mod_archive2 ? Thanks you so much.

huyd commented 10 years ago

yeah, it worked. I have changed xmlns from 'http://www.xmpp.org/extensions/xep-0136.html#ns' to 'urn:xmpp:archive' But i got same errors as @nobelium post above. Messages didn't store in mysql database.

<body xmlns="http://jabber.org/protocol/httpbind">
   <iq xmlns="jabber:client" from="52d3f1b237b9d2740d73fcac@192.168.2.91" to="52d3f1b237b9d2740d73fcac@192.168.2.91/webchat-3160" id="4404:list" type="result">
      <list xmlns="urn:xmpp:archive" />
   </iq>
</body>
nobelium commented 10 years ago

Hi @huyd, any luck? Are the messages getting stored?

huyd commented 10 years ago

hi @nobelium, No, the messages didn't store. I've changed from mysql to postgres but nothing changed. Hope @ndl help us.

nobelium commented 10 years ago

@huyd same here.. @ndl please help.

ndl commented 10 years ago
  1. Please search your log for any error messages from mod_archive2, it's hard to say what's going on exactly without seeing actual errors.
  2. How exactly are you checking that messages aren't stored? Please send the XML log of the full communication - that is, message being send to / from the client that is supposed to be achieved, then the request you're sending to get the list of messages from the server and the empty response you're getting.
  3. Please try storing messages manually - that is, manually upload the collection in XML console of your client using an example from "5.2 Uploading Messages to a Collection" section in XEP-136 specification, and then see whether you're getting any error back and if not - whether these messages are stored or not.
nobelium commented 10 years ago

@ndl , I'm still not able to figure out why mod_archive2 is not working.

This is my ejabberd config file https://gist.github.com/nobelium/9031942

None of the log files have the word mod_archive2 except for erlang.log https://gist.github.com/nobelium/26f1974f681fb0ec7929

I tried to manually store messages, but i'm not getting any reply. (using strophe) @conn.send($iq({type: "set", id:"asdf"}).c("save", {xmlns: "urn:xmpp:archive"}).c("chat",{with: "vignesh@courseshub/asdf", thread: "adfeesfadf", subject: "some sub", start: '1469-07-21T02:56:15Z'}).c("from", {sec: '0'}),c("body").t("some chat message"))

I think some thing is wrong with the config file. mod_archive_odbc is working fine though. If mod_archive_odbc is being supported now, I'm ready to go with it.

nobelium commented 10 years ago

The only reason that I'm trying to move from mod_archive_odbc to mod_archive2 is because of this issue http://www.ejabberd.im/mod_archive#comment-59230

ndl commented 10 years ago

RE: "getting no reply" - this is really strange, you might want to enable debugging in ejabberd log to get not only error, but also debug messages, and then see at what point incoming message processing stops.

"mod_archive_odbc is working fine though" - I assume you're talking about different installation now, right? mod_archive_odbc and mod_archive2 use different DB schema so cannot work with the same DB.

RE: "Problem with mod_archive_odbc and offline messages" - try commenting out the call to add / remove hook for 'offline_message_hook', this should store messages only once they're actually delivered to the client that became online.

nobelium commented 10 years ago

@ndl the log type is already set to debug(you can see it in the config file). I'm not getting anything related to mod_archive2. Its frustrating to spend so much time on just compiling and installing a module. Please add a detailed readme to the repo.