Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php asynchronous cURL request

I am developing a website with PHP and sending requests with cURL.

I have a website, that does some calculations, that I need to get a response from. I am sending requests via cURL Currently what I'm doing is to send a request, wait 10 sec and send it again (max 3 times), if no "good" response is received. If all request fail, I flag them for "manual fix".

The thing is I want to send a request with 30 sec timeout, and on the 10th second, if no response is received, to send another one with 20 sec timeout, on the 20th second to send last one with 10 sec timeout. Is such thing possible?

Or if my current code remains and I continue to send requests every 10th second with timeout 10 sec each, can I continue to listen to the first one after I send the second (and first and second when I'm sending the third)?

Thank you in advance!

like image 658
Dimitar Dimov Avatar asked Feb 10 '23 20:02

Dimitar Dimov


1 Answers

Use blow to make async curl call

    curl_setopt($crl, CURLOPT_TIMEOUT, 1);
    curl_setopt($crl, CURLOPT_NOSIGNAL, 1);

PHP SetOpt

like image 196
Praveen D Avatar answered Feb 12 '23 10:02

Praveen D