Search code examples
erlangxmppejabberd

'error {badmatch,{error,enoent}}' occurred executing push_roster command on ejabberd


I am trying to add bulk contacts to user's roster in ejabberd. I am using default Mnesia database with ejabberd. I have created a file sampleRosterFile. In this file contents are

[{"kunal", "localhost", "Friend List", "kunal"},{"Rich", "localhost", "Friend List", "Rich"}]

I am executing command

sudo ejabberdctl push_roster /home/kunal/Projects/demo/sampleRosterFile kunal localhost

But i am getting error

Problem 'error {badmatch,{error,enoent}}' occurred executing the command.
Stacktrace: [{mod_admin_extra,push_roster,3,
                              [{file,"src/mod_admin_extra.erl"},{line,1145}]},
             {ejabberd_commands,execute_command2,2,
                                [{file,"src/ejabberd_commands.erl"},
                                 {line,410}]},
             {ejabberd_ctl,call_command,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,295}]},
             {ejabberd_ctl,try_call_command,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,271}]},
             {ejabberd_ctl,process2,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,220}]},
             {ejabberd_ctl,process,1,
                           [{file,"src/ejabberd_ctl.erl"},{line,205}]},
             {rpc,'-handle_call_call/6-fun-0-',5,
                  [{file,"rpc.erl"},{line,206}]}]

As per recent developments, i have made my roster file to .txt and tried again. but now that is giving me error something related to string

sudo ejabberdctl push_roster /home/kunal/Projects/demo/ejabberd/ebin/sampleRosterFile.txt kunal localhost
Problem 'error function_clause' occurred executing the command.
Stacktrace: [{jid,to_string,[error],[{file,"src/jid.erl"},{line,134}]},
             {mod_admin_extra,build_roster_item,3,
                              [{file,"src/mod_admin_extra.erl"},{line,1200}]},
             {mod_admin_extra,subscribe,8,
                              [{file,"src/mod_admin_extra.erl"},{line,1088}]},
             {mod_admin_extra,subscribe_roster,2,
                              [{file,"src/mod_admin_extra.erl"},{line,1167}]},
             {ejabberd_commands,execute_command2,2,
                                [{file,"src/ejabberd_commands.erl"},
                                 {line,410}]},
             {ejabberd_ctl,call_command,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,295}]},
             {ejabberd_ctl,try_call_command,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,271}]},
             {ejabberd_ctl,process2,3,
                           [{file,"src/ejabberd_ctl.erl"},{line,220}]}]

Need help here.


Solution

  • Earlier code was giving me enoent error, which was correctly pointed out by @Mickaël Rémond It will be helpful to give full path of the roster file.

    Next is error function_clause error which mean that no function or signature is matching with my input.

    after debugging found that correct file format for push_roster command in mod_admin_extra is

    [{<<"admin">>,<<"localhost">>,<<"Friend">>,<<"Admin">>},{<<"anil">>,<<"localhost">>,<<"Friend">>,<<"Anil">>}]
    

    It finally worked.

    I found helpful explaination on the blog http://www.techiekunal.in/2016/04/ejabberd-bulk-roster-addition-using-pushroster.html