ashgromnies
ashgromnies

Reputation: 3335

PEAR and PHP -- "Error getting channel info" on OS X when upgrade/do anything

I saw this question: Problem with update pear that said the issue is using an outdated version of PEAR, well, I'm using 1.9.4(the latest).

dinosaurhunter:~ root# pear -V
PEAR Version: 1.9.4
PHP Version: 5.3.21
Zend Engine Version: 2.3.0
Running on: Darwin dinosaurhunter.network.local 12.2.1 Darwin Kernel Version 12.2.1: Thu Oct 18 16:32:48 PDT 2012; root:xnu-2050.20.9~2/RELEASE_X86_64 x86_64

I am using PHP from homebrew.

So weird:

dinosaurhunter:~ root# pear upgrade
Error getting channel info from pear.php.net: Connection to `pear.php.net:80' failed: Operation timed out
Error getting channel info from pear.php.net: Connection to `pear.php.net:80' failed: Operation timed out
Error getting channel info from pear.php.net: Connection to `pear.php.net:80' failed: Operation timed out
Error getting channel info from pear.php.net: Connection to `pear.php.net:80' failed: Operation timed out
Error getting channel info from pear.php.net: Connection to `pear.php.net:80' failed: Operation timed out
Nothing to upgrade

dinosaurhunter:~ root# curl pear.php.net:80 | head -n5
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14420    0 14420    0     0  41953      0 --:--:-- --:--:-- --:--:-- 66759
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
<link rel="alternate" href="http://blog.pear.php.net/feed/" type="application/rss+xml" title="PEAR News" /> <title>PEAR - PHP Extension and Application Repository</title>
 <link rel="shortcut icon" href="/gifs/favicon.ico" />

I saw some people saying it's a proxy thing -- I don't use a proxy either.

dinosaurhunter:~ root# pear config-show | grep -i proxy
HTTP Proxy Server Address      http_proxy       <not set>

I'm really lost because the URLs they say are timing out work just fine, I'm not using a proxy, PEAR is up to date -- what else could it be?

EDIT did more debugging...

This code works:

<?php


error_reporting(E_ALL);
ini_set('display_errors', 1);

ini_set ('allow_url_fopen', 1);

$url = 'http://www.google.com';

// Create a stream
$opts = array(
  'http'=>array(
    'timeout'=>60,
  )
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents($url, false, $context);

var_dump($file);

However, this doesn't work:

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

ini_set ('allow_url_fopen', 1);

$file = file_get_contents('http://www.google.com/');
var_dump($file);

It fails with:

Warning: file_get_contents(http://www.google.com/): failed to open stream: Operation timed out

Upvotes: 0

Views: 1668

Answers (2)

ashgromnies
ashgromnies

Reputation: 3335

The underlying issue wound up being the default_socket_timeout configuration.

It was set like:

; Default timeout for socket based streams (seconds)
; http://php.net/default-socket-timeout
default_socket_timeout = unlimited

I changed it to

; Default timeout for socket based streams (seconds)
; http://php.net/default-socket-timeout
default_socket_timeout = 120

and it works.

It looks like file_get_contents might not respect a default_socket_timeout value of "unlimited". Blargh!

Upvotes: 1

cweiske
cweiske

Reputation: 31078

Run wireshark and check what pear actually does network-wise. You can also run pear -vvvvvv to get debug output - that might give you a hint about the problem source.

Upvotes: 0

Related Questions