문제

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!

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top