php - Timeout and unset 1 query in multi curl


I have php script that send request to the other server.

If the question similar to each other, I using multi curl

try {                                                                
    $result['response'][] = @new SimpleXMLElement($task);               
    $result['request'][] = @new SimpleXMLElement($request);             

} catch (Exception $e) {                                             
    // Showing err
    if ($throwException) {                                              
        throw new Exception('Internal Server Error', 500);            

If any problem with answer I showing an error.

I want to know:

1) How to understand that it was timeout error or something else?

$cmh = curl_multi_init(); // create only one descriptor

If I send 5 request, 4 will be ok, and by 1 will be timeout()

2) How to unset only this one request in multi curl?





I'd recommend this CURL class:

$curl = new CURL();
$curl->retry = 2;
$curl->addSession( '', $opts );
$curl->addSession( '', $opts );
$curl->addSession( '', $opts );
$result = $curl->exec();
foreach( $result as $r )
    if( $r['info']['http_code'] !== 200 )
        echo $r['url'] . " has failed\n";

I may have some of the variables in the foreach wrong there. Just print_r( $r['info'] ); and you will get all the details for each request. This also has a retry for failed requests ($curl->retry = 2;).

People are also looking for solutions to the problem: javascript - Not getting the success callback for an ajax query to my php page


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.