• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

[API RPC] 'Error 324 (net::ERR_EMPTY_RESPONSE)'

MariuszS

New Pleskian
Hi there.

I've got problem with subscription creation by API call.

I'm net getting response from curl when subscription is created.

With account creation (customer) I'm getting normal response.

Also when I'm trying to create subscription with domain which already exists in panel I'm getting normal response from API.

I will try to reproduce that:

1. making call to create subscription
2. getting empty response (subscription created in plesk panel)
3. trying call again subscritpion creation with the same parameters send previously
4 getting error from API about that domain already exists.

this is my code with deleted IP, and login details
class Plesk {

public function _makeRequest($params) {
$headers = array(
'HTTP_AUTH_LOGIN: xxxxxxxx',
'HTTP_AUTH_PASSWD: xxxxxxxxx',
'Content-Type: text/xml'
);

$xml = $this->_arrayToXml($params, new SimpleXMLElement('<packet version="1.6.3.0"></packet>'))
->asXML();

$ch = curl_init ();
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt ($ch, CURLOPT_URL, 'https://domain.com:8443/enterprise/control/agent.php');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_TIMEOUT, 480);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml);
//debug
curl_setopt($ch, CURLOPT_VERBOSE, true);


$result = curl_exec($ch);

if (curl_errno ($ch)) {
echo curl_errno ($ch) . ' - ' . curl_error ($ch);
}
curl_close($ch);
return $this->_parseResponse($result);
}

private function _arrayToXml(array $arr, SimpleXMLElement $xml) {
$numbers = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
foreach ($arr as $k => $v) {
if (is_array($v)) {
$this->_arrayToXml($v, $xml->addChild(str_replace($numbers, '', $k)));
} else {
$xml->addChild(str_replace($numbers, '', $k), $v);
}
}
return $xml;
}

private function _parseResponse($result) {
try {
$xml = simplexml_load_string($result, 'SimpleXMLElement', LIBXML_NOCDATA);
} catch (Exception $e) {
echo 'simpleXmlException: '.$e->getMessage();
}

return $xml;
}

public function toArray(SimpleXMLElement $xml) {
$array = (array)$xml;

foreach ( array_slice($array, 0) as $key => $value ) {
if ( $value instanceof SimpleXMLElement ) {
$array[$key] = empty($value) ? NULL : $this->toArray($value);
}
}
return $array;
}
}

$params = array(
'webspace' => array(
'add'=>array(
'gen_setup'=> array(
'name' => 'test.com',
'ip_address' => 'xxx.xxx.xxx.xxx',
'status' => '0',
),
)
),
);

$plesk= new Plesk;
$result=$plesk->_makeRequest($params);
var_dump($result);
 
Same problem

Did you ever get any help with this? I have exactly the same problem. Error 'Domain already exists' but the Customer and subscription are created correctly. I need to retrieve the ID and GUID after creation but it returns just the error string if you check the page source code.
The return page shows: Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data. but the source does show the error if you echo it in your script by viewing page source.

Paul.
 
When the subscription is created, I noticed that the plesk creates a file in /usr/local/psa/var/httpd_restart

As apache is restarted, and the connection is lost.
 
Back
Top