Bolt: [BUG] Curl error: Curl: error (6) : name lookup timed out - But only in Bolt!

Created on 15 Apr 2016  Â·  3Comments  Â·  Source: bolt/bolt

Details

  • Relevant Bolt Version: 2.2.19-pl1
  • Install type: Zip/tarball install
  • PHP version: 5.5 && 5.6 && 7.0
  • Used webserver: Apache version 2.2.22-13+deb7u6
  • For UX/UI issues: Chrome

    Reproduction

1) Go to extensions and you'll see the Extras ⇒ View & Install Extensions:

Testing connection to extension server failed: cURL error 6: name lookup timed out
https://extensions.bolt.cm/ is unreachable.

If I use curl at CLI, it works well with https://extensions.bolt.cm/.
For testing purposes, I've created a scipt:

<?php 

function nxs_cURLTest($url, $msg, $testText){  
  $ch = curl_init(); 
  curl_setopt($ch, CURLOPT_URL, $url); 
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36"); 
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
  curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
  $response = curl_exec($ch); 
  $errmsg = curl_error($ch); 
  $cInfo = curl_getinfo($ch); 
  curl_close($ch); 
  echo "Testing ... ".$url." - ".$cInfo['url']."<br />";
  if (stripos($response, $testText)!==false) {
    echo "....".$msg." - OK<br />"; 
    echo "<br> Response-Data:<br>";
    print_r(htmlentities($response)); 
}
  else 
  { 
    echo "....<b style='color:red;'>".$msg." - Problem</b><br /><pre>"; 
    print_r($errmsg); 
echo "<br> cInfo:</br>";
    print_r($cInfo); 
    print_r(htmlentities($response)); 
    echo "</pre>There is a problem with cURL. You need to contact your server admin or hosting provider.";
  }
}
nxs_cURLTest("https://extensions.bolt.cm/", "HTTPS to NXS", "bolt");
?>

Also works fine, and output HTML of the Extension-Page. Even tried to use http: instead of https, with same result (error msg).

So wonder why curl within bolt not work at all!

needs verification

Most helpful comment

Have try to debug the Problem.

So I opend /vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php/ and change the line 377:

        if (isset($options['connect_timeout'])) {
            $conf[CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000;
        }

I have change the last Number to 10000, save, and reload the Bolt-Backend.
Then the failure-Message disappear.

I think it is a very important knowledge. Please add it to the documentations here: https://docs.bolt.cm/3.0/howto/curl-ca-certificates#version-changer (or in an own topic).

All 3 comments

Problem still exist on Bolt 3.0.0

Have try to debug the Problem.

So I opend /vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php/ and change the line 377:

        if (isset($options['connect_timeout'])) {
            $conf[CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000;
        }

I have change the last Number to 10000, save, and reload the Bolt-Backend.
Then the failure-Message disappear.

I think it is a very important knowledge. Please add it to the documentations here: https://docs.bolt.cm/3.0/howto/curl-ca-certificates#version-changer (or in an own topic).

You can change the "connect_timeout" value in vendor/bolt/bolt/src/Composer/PackageManager.php on line 394:

$this->app['guzzle.client']->head($uri, ['query' => $query, 'exceptions' => true, 'connect_timeout' => 5, 'timeout' => 10]);```

Was this page helpful?
0 / 5 - 0 ratings