Proxy CONNECT aborted due to timeout PHP curl

Рейтинг: 0Ответов: 1Опубликовано: 21.12.2014

Частенько появляется ошибка:

Proxy CONNECT aborted due to timeout

Как исправить?

  $ch = curl_init($url);

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
  curl_setopt($ch, CURLOPT_TIMEOUT, 20);
  curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  curl_setopt($ch, CURLOPT_REFERER, '');

  if($params) {
   curl_setopt($ch, CURLOPT_HTTPHEADER, array( 
    'X-Insta-Forwarded-For: '.$x_forwarded_for
   ));
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
  }

  // PROXY
  if($proxy) {
   curl_setopt($ch, CURLOPT_PROXY, $proxy);
  }

  $result = curl_exec($ch);
  $error = curl_error($ch);

  return (($error) ? array('error_type' => 'curl', 'error_text' => $error) : $result);

  curl_close($ch);

Ответы

Ответов пока нет.