Hey there,

i'm trying to control the kea server by using the control agent.

I already implemented a web-frontend to the database (mysql) to show all the 
leases and reservations.
Now I'm trying to get the running configuration by requesting the control agent.

$msg = array("command" => "config-get", "service" => "[ dhcp4 ]");
$message = json_encode($msg);

//$message = '{ "command": "config-get", "service": "dhcp4" }';
$len = strlen($message);

echo print_r($message, true), "\n";

$ch = curl_init('');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $message);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
     'Content-type: application/json',
     'Content-Length: '. $len)
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);

$ret = curl_exec($ch);
if($ret === false)
    echo 'Curl error: ' . curl_error($ch);
     echo print_r($ret, true);
    echo 'Operation completed without any errors';

All I receive is the following:
{"command":"config-get","service":"[ dhcp4 ]"}
{ "result": 400, "text": "Bad Request" }
Operation completed without any errors

I tried a lot of things:

-       dhcp4 with or without brackets

-       using the documented string 

-       with and without timeouts

-       different HTTPHEADER (with, and without Content-Length like in the 

The service is up and running, if i'm using the shell and curl the example 
I also tried to get a clue by reading the log (DEBUG, Level 99) but there is 
just a lousy message "HTTP_DATA_RECEIVED received 152 bytes from" and 
"DEBUG [kea-ctrl-agent.http] HTTP_RESPONSE_SEND sending HTTP response HTTP/1.1 
400 Bad Request#015#012 to"

Does anybody have a clue how to successfully connect and receive a proper 

Thanks in advance

Kea-users mailing list

Reply via email to