XMLRPC Error

I've downloaded the ejabberd xmlrpc module from http://www.ejabberd.im/ejabberd_xmlrpc. I've compiled it and added it to the ejabberd beams folder. I also added {4560, ejabberd_xmlrpc, [{maxsessions, 10}, {timeout, 5000}]}, to my config file. But after a restart of ejabberd, I get the following error in my ejabberd.log file.

=ERROR REPORT==== 2011-01-18 13:50:37 ===
E(<0.36.0>:ejabberd_listener:272) : Error starting the ejabberd listener: ejabberd_xmlrpc.
It could not be loaded or is not an ejabberd listener.
Error: {{'EXIT',{undef,[{xmlrpc,start_link,
                                [{0,0,0,0},
                                 4560,10,5000,
                                 {ejabberd_xmlrpc,handler},
                                 {state,[],noauth,false}]},
                        {supervisor,do_start_child,2},
                        {supervisor,handle_start_child,2},
                        {supervisor,handle_call,3},
                        {gen_server,handle_msg,5},
                        {proc_lib,init_p,5}]}},
        {child,undefined,
               {4560,{0,0,0,0},tcp},
               {ejabberd_listener,start,
                                  [{4560,{0,0,0,0},tcp},
                                   ejabberd_xmlrpc,
                                   [{maxsessions,10},{timeout,5000}]]},
               transient,brutal_kill,worker,
               [ejabberd_listener]}}

=INFO REPORT==== 2011-01-18 13:50:37 ===
    application: ejabberd
    exited: {bad_return,{{ejabberd_app,start,[normal,[]]},
                         {module_not_available,xmlrpc}}}
    type: temporary

The compiled file is in the beams folder, so why is the module not available? Does this have to do with the patch information listed on the module home page?

I found the compiled files

I found the compiled files for the xmerl patch and placed them in ejabberd-x.x.x\lib\kernel-x.x.x\ebin and ejabberd started up normally. Now to see if it works :)

Seems like now I've run up

Seems like now I've run up against another error:

PHP Warning: file_get_contents(http://127.0.0.1:4560/RPC2): failed to open stream: HTTP request failed!

I've checked to make sure that ejabberd is listening on that port. Is there something else I need to setup? Where does the /RPC2 come from?

Try this script

ashansky wrote:

Where does the /RPC2 come from?

Maybe from the erlang xmlrpc library.

ashansky wrote:

PHP Warning: file_get_contents(http://127.0.0.1:4560/RPC2): failed to open stream: HTTP request failed!

I've checked to make sure that ejabberd is listening on that port.

You should get something like this:

$ netstat -pnl | grep 4560                                                                             
(Not all processes could be identified, non-owned process info                                         
 will not be shown, you would have to be root to see it all.)                                          
tcp        0      0 0.0.0.0:4560            0.0.0.0:*               LISTEN      29644/beam.smp 
$ telnet 127.0.0.1 4560                                                                                 
Trying 127.0.0.1...                                                                                     
Connected to 127.0.0.1.                                                                                 
Escape character is '^]'.                                                                               

hello                                                                                                   

HTTP/1.1 400 Bad Request                                                                                
Content-Length: 0                                                                                       
Server: Erlang/1.13                                                                                     
Content-Type: text/xml    
ashansky wrote:

Is there something else I need to setup?

I found this PHP script file:

<?
$param=array("host"=>"localhost");
$request = xmlrpc_encode_request('registered_users', $param, (array('encoding' => 'utf-8')));

$context = stream_context_create(array('http' => array(
    'method' => "POST",
    'header' => "User-Agent: XMLRPC::Client mod_xmlrpc\r\n" .
                "Content-Type: text/xml\r\n" .
                "Content-Length: ".strlen($request),
    'content' => $request
)));

$file = file_get_contents("http://127.0.0.1:4560/RPC2", false, $context);

$response = xmlrpc_decode($file);

if (xmlrpc_is_fault($response)) {
    trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
} else {
    print_r($response);
}
?>

I have two account registered. When i run that script, I get this:

$ php 4504-registered-works.php
Array
(
    [users] => Array
        (
            [0] => Array
                (
                    [username] => badlop
                )

            [1] => Array
                (
                    [username] => badlop2
                )

        )

)

I've made sure that ejabberd

I've made sure that ejabberd is listening on port 4560, but I receive this error whenever I try to run a command.

PHP Warning: file_get_contents(http://127.0.0.1:4560/RPC2): failed to open stream: HTTP request

Code

protected /*string*/ function sendRequest(/*string*/$command,/*array*/$params){
//check that params is array if not create
if(!is_array($params)){
$params = array();
}
//$params["user"] = "admin";
//$params["host"] = "localhost";

$request = xmlrpc_encode_request($command, $params, (array('encoding' => 'utf-8')));

$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "User-Agent: XMLRPC::Client mod_xmlrpc\r\n" .
"Content-Type: text/xml\r\n" .
"Content-Length: ".strlen($request),
'content' => $request
)));

$file = file_get_contents("http://127.0.0.1:4560/RPC2", false, $context);

$response = xmlrpc_decode($file);

if (xmlrpc_is_fault($response)) {
trigger_error("xmlrpc: $response[faultString] ($response[faultCode])");
} else {
return $response;
}
}

Syndicate content