【发布时间】:2014-02-19 14:23:15
【问题描述】:
我在运行 PHP 5.5.8 的 CentOS 6.4 机器 (2.6.32-431.3.1.el6.i686) 遇到了一个奇怪的问题。 自从我们将 cURL / libcurl 升级到 7.34 版后,所有 Facebook 应用程序都停止了工作。它只是在尝试执行“curl_exec($ch)”时超时。
使用 yum downgrade 和 yum install curl libcurl,我能够重现错误(并且始终有效),请在此处查看 phpinfo() 的差异:
尝试以详细模式运行 curl 并捕获发送和接收的数据。
如果其他人想知道如何捕获此 cURL 数据(不容易找到):
$opts[CURLOPT_VERBOSE] = true; // enable verbose logging
$verbose = fopen('php://temp', 'rw+');
$opts[CURLOPT_STDERR] = $verbose;
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
rewind($verbose);
$verboseLog = stream_get_contents($verbose);
echo "Verbose information:\n<pre>". htmlspecialchars($verboseLog), "</pre>\n";
这适用于 7.19.7:
* About to connect() to graph.facebook.com port 443 (#0)
* Trying 173.252.101.48... * connected
* Connected to graph.facebook.com (173.252.101.48) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using SSL_RSA_WITH_RC4_128_SHA
* Server certificate:
* subject: CN=*.facebook.com,O="Facebook, Inc.",L=Palo Alto,ST=California,C=US
* start date: Oct 28 00:00:00 2013 GMT
* expire date: Aug 05 23:59:59 2015 GMT
* common name: *.facebook.com
* issuer: CN=VeriSign Class 3 Secure Server CA - G3,OU=Terms of use at https://www.verisign.com/rpa (c)10,OU=VeriSign Trust Network,O="VeriSign, Inc.",C=US
> POST /me HTTP/1.1
User-Agent: facebook-php-3.2
Host: graph.facebook.com
Accept: */*
Content-Length: 232
Content-Type: application/x-www-form-urlencoded
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Cache-Control: private, no-cache, no-store, must-revalidate
< Content-Type: application/json; charset=UTF-8
< ETag: "a4238b670d50df51506644bd20277a7cffbfaa80"
< Expires: Sat, 01 Jan 2000 00:00:00 GMT
< Last-Modified: 2014-01-15T13:20:35+0000
< Pragma: no-cache
< X-FB-Rev: 1097933
< X-FB-Debug: ekyERaUVGaiB7H+tLQn1m6sll33KkF8CUhlHGd9/lGs=
< Date: Tue, 28 Jan 2014 09:51:40 GMT
< Connection: keep-alive
< Content-Length: 253
<
* Connection #0 to host graph.facebook.com left intact
当尝试对 7.34.0 执行相同操作时,httpd 以 100% 运行并在 30 秒后超时(或任何在 php.ini 中设置的内容)。根本没有详细的输出,只是超时。在 Apache error_log 中找不到任何内容。
任何想法如何进一步调试?
问候, 最大
【问题讨论】:
标签: php facebook api curl libcurl