2
votes

I am trying to call ejabberdctl from PHP but i keep getting an error code of 3 (Failed RPC connection to the node ejabberd@localhost: nodedown).

My PHP script contains the following code to add friends :

exec('sudo /opt/ejabberd-2.1.2/bin/ejabberdctl add_rosteritem adil.baig40122310029739 godudu.com chburaska0822431111022397 godudu.com chburaska0822431111022397 Friends both', $output, $retCode);

exec('sudo /opt/ejabberd-2.1.2/bin/ejabberdctl add_rosteritem chburaska0822431111022397 godudu.com adil.baig40122310029739 godudu.com adil.baig40122310029739 Friends both', $output, $retCode);

I have also added ejabberdctl to /etc/sudoers like so :

# Custom entry for ejabberdctl, so it can be used via PHP
www-data ALL= NOPASSWD: /opt/ejabberd-2.1.2/bin/ejabberdctl

I have also added the ejabberd bin directory to /etc/environment, like so :

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/ejabberd-2.1.2/bin"
source /etc/environment

Everytime i run the PHP script $retCode (the exec return code) returns 3, but if i run the same php file from the command line it works.

Help!

1
Update : by replacing 'exec' with 'system' i get the following output "Failed RPC connection to the node ejabberd@localhost: nodedown" Although if i run "ejabberdctl status" it shows the server is runningAdil
I can see in the ejabberd logs the following error message : "Connection attempt from disallowed node 'ejabberd-ctl@localhost'"Adil

1 Answers

1
votes

It turns out that this was a cookie (Erlang cookie) problem. For the answer see ejabberdctl does not work from PHP