[英]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). 我看到了一个问题: 更新pear的问题是该问题使用的是PEAR的过时版本,嗯,我使用的是1.9.4(最新版本)。
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. 我正在使用自制软件的PHP。
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? 我真的迷失了,因为他们说的超时URL可以正常工作,我没有使用代理,PEAR是最新的-还能是什么?
EDIT did more debugging... EDIT进行了更多调试...
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警告:
file_get_contents(http://www.google.com/)
:无法打开流:操作超时
The underlying issue wound up being the default_socket_timeout
configuration. 根本的问题是
default_socket_timeout
配置。
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". 看起来
file_get_contents
可能不尊重default_socket_timeout
值“ unlimited”。 Blargh! lar!
Run wireshark and check what pear actually does network-wise. 运行wireshark,并检查梨实际上是从网络角度执行的。 You can also run
pear -vvvvvv
to get debug output - that might give you a hint about the problem source. 您还可以运行
pear -vvvvvv
以获得调试输出-可能会提示您有关问题的根源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.