views:

254

answers:

2

Hi,

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!

A: 

It turns out that this was a cookie (Erlang cookie) problem. For the answer see http://stackoverflow.com/questions/2424374/ejabberdctl-does-not-work-from-php

Adil
A: 

Hi I'm trying to do the same way, but I'm getting retCode= 11.

any suggestion?

sarog
You should post follow-up questions as a separate thread, notas an answer. After all, it doesn't really answer *this*question. Also more people would see it and try to answer if you post it asyour own question.
sth