Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


curl_exec not catching no connection/timeout

crmpiccocrmpicco Member Posts: 12
Fatal error: Maximum execution time of 60 seconds exceeded in C:wampwwwpath on line 102

I am receiving this error with the following code, the domain that I am using has been removed from my hosts file for testing purposes so that I can test where there is no connection to the server for example. Does anyone know why I would be getting this fatal error? I realise that curl_exec doesn't throw exceptions, but I cannot seem to find a way to stop or handle the fatal error?

From the PHP documentation it reads that the CURLOPT_CONNECTTIMEOUT option should come into play when it cannot connect to the domain.

If I have not properly explained it before I removed the entry from my hosts file so that my machine could not lookup the IP, for example:

These are example values and are just for illustration.

// create the headers
$headers = array(
"POST HTTP/1.0",
"Content-type: text/xml;charset="utf-8"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"Content-length: ".strlen($xml)

// create a new cURL session
$ch = curl_init();

// set a range of options for this cURL session
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 25);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

// send the request and store the result in an array
try {
$data = curl_exec($ch); // <-- errors here
catch (Exception $e) {
throw new Exception("Error with cURL request");



  • crmpiccocrmpicco Member Posts: 12
    I managed to find a solution to this without having to use exceptions and the like. Please see the code below, I hope it can be of help to someone researching this code at some point in the future

    protected function dispatch() {

    // .... code ....

    $dispatcher_conn_issue = false;

    // send the request off to Sabrix
    $data = curl_exec($ch);

    // check if we cannot find the host
    if (empty($data)) {
    // set a flag to donate a connection issue
    $dispatcher_conn_issue = true;

    $picco_info["status"] = "Failure";
    $picco_info["statusinfo"] = "Failed Request";


    if (!$dispatcher_conn_issue) {

    // ... rest of my code ...


    $this->piccoval = $picco_info; // member variable set here

Sign In or Register to comment.