cURL is making apache to consume most of the cpu
Posted by: prueba2306 (---.prod-infinitum.com.mx)
Date: March 24, 2024 06:50PM

I'm trying to interact with Whatsapp API using PHP cURL. The code is simple, send a POST request to send a message to a phone. That's it. It works, sends the message without issues. The problem begins after that.

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "[graph.facebook.com]winking smiley;
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode([
'messaging_product' => 'whatsapp',
'to' => '<PHONE_NUMBER_TO_SEND>',
'type' => 'template',
'template' => [
'name' => 'hello_world',
'language' => [
'code' => 'en_US',
],
],
]));
curl_setopt($curl, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <TOKEN>",
'Content-Type: application/json',
]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
var_dump($response);

Normally Apache does not consume any CPU at all but after I run the code previously showed, it starts to increment the CPU consumption until it reach 80% or more.

After that I need to restart the Apache server.

Is there something I can do to avoid this?

I updated WampServer to the last available update (3.3.2). I'm using Apache 2.4.58, PHP 8.3.0 and MySQL 8.2.0 on a PC Windows 10 Pro Version 22H2. The Apache server is using an SSL instaled with CertBot.

For screenshots you can see this url [stackoverflow.com]

Options: ReplyQuote
Re: cURL is making apache to consume most of the cpu
Posted by: Otomatic (Moderator)
Date: March 24, 2024 07:21PM

Hi,

It is a problem with xDebug and PHP 8.3.*
Disable xDebug.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: cURL is making apache to consume most of the cpu
Posted by: prueba2306 (---.prod-infinitum.com.mx)
Date: March 24, 2024 07:54PM

Thank you! It worked.

Options: ReplyQuote


Sorry, only registered users may post in this forum.