Jump to content

Curl api error: Operation timed out after 1000 milliseconds with 0 bytes received


Hamendra Sunthwal

Recommended Posts

I am trying to send 200 orders to an api using curl but timeout occurs

Curl api error: Operation timed out after 1000 milliseconds with 0 bytes received

Here is the code i am using

$ch = curl_init();
                curl_setopt($ch, CURLOPT_URL, "http://api-r1.smartfreight.com/api/soap/classic");
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_USERPWD, "[email protected]:World#10");
                curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
                curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml; charset=utf-8", "soapAction: http://www.smartfreight.com/online/SFOv1/Import", "Content-Length: " . strlen($data)));
                curl_setopt($ch, CURLOPT_TIMEOUT,5000);
                $output = curl_exec($ch);
    
                //~ if($output === false && curl_errno($ch) == CURLE_OPERATION_TIMEOUTED){
                    //~ continue;
                //~ }else 
                if($output === false){
                    echo "\nCurl api error: ".curl_error($ch);
                }

is there any quick fix for this issue ?

Thankyou

Edited by Hamendra Sunthwal (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...