Hi List,

I'm trying to use Supervisor's XML-RPC interface from PHP with not
much success so far.

Here's my code:

<?php

$xml = xmlrpc_encode_request("getSupervisorVersion", NULL,
array('encoding'=>'utf-8'));

print "* Request:\n$xml";
$crlf = "\r\n";
$request = 'POST / HTTP/1.1' . $crlf;
$request .= 'Content-Length: '. strlen($xml) . $crlf;
$request .= $crlf;
$request .= $xml;

$sock = fsockopen('unix:///var/run/supervisor.sock', NULL, $errno, $errstr);
fwrite($sock, $request);

$response = fread($sock, 1000000);
print "* Response:\n$response\n";

//$response = xmlrpc_decode($file);
//if ($response && xmlrpc_is_fault($response)) {

?>

Which outputs:

* Request:
<?xml version="1.0" encoding="utf-8"?>
<methodCall>
<methodName>getSupervisorVersion</methodName>
<params/>
</methodCall>
* Response:

As you can see the response is empty.  However, upon removing the
Content-Length HTTP header I get this:

* Request:
<?xml version="1.0" encoding="utf-8"?>
<methodCall>
<methodName>getSupervisorVersion</methodName>
<params/>
</methodCall>
* Response:
HTTP/1.1 411 Length Required
Date: Tue, 14 Aug 2012 16:59:36 GMT
Content-Length: 140
Content-Type: text/html
Server: Medusa/1.12

<head>
<title>Error response</title>
</head>
<body>
<h1>Error response</h1>
<p>Error code 411.
<p>Message: Length Required.
</body>

So it looks like things are working HTTP-wise Supervisor doesn't
answer my RPC calls.  Anyone could give me some help, please?

Thanks in advance!

-- 
László Monda <http://monda.hu>
_______________________________________________
Supervisor-users mailing list
Supervisor-users@lists.supervisord.org
http://lists.supervisord.org/mailman/listinfo/supervisor-users

Reply via email to