【发布时间】:2014-08-28 17:25:52
【问题描述】:
我正在尝试在我最近基于 Zend Framework 2 构建的项目中使用 AWS S3。
发生了一些非常奇怪的事情,我一直无法找到解决方案。
我启动了一个全新的 Zend Framework 2 Skeleton 应用程序并通过 composer 安装了aws/aws-sdk-php。
创建了一个简单的 S3::putObject 请求:
$client = S3Client::factory(array(
'key' => 'xxx',
'secret' => 'xxx',
'region' => 'xxx',
));
$client->putObject(array(
'Bucket' => $bucket,
'Key' => '/test/test.html',
'Body' => 'This is a test' . time(),
'ContentType' => 'text/html',
'Acl' => CannedAcl::PUBLIC_READ
));
当我在 PHPUnit 中测试上面的代码时,它运行良好。但是,当我打开浏览器查看来自同一个 IndexController 的结果时,Firefox 只是报告“连接已重置”。 PHP 不会抛出任何异常
我打开Apache的错误日志看到:
[Tue Jul 08 04:58:58 2014] [notice] child pid 33428 exit signal Segmentation fault (11)
[Tue Jul 08 04:59:15 2014] [notice] child pid 33439 exit signal Segmentation fault (11)
[Tue Jul 08 04:59:16 2014] [notice] child pid 33361 exit signal Segmentation fault (11)
[Tue Jul 08 05:02:02 2014] [notice] child pid 33452 exit signal Segmentation fault (11)
[Tue Jul 08 05:02:50 2014] [notice] child pid 33142 exit signal Segmentation fault (11)
[Tue Jul 08 05:04:34 2014] [notice] child pid 33317 exit signal Segmentation fault (11)
[Tue Jul 08 05:04:35 2014] [notice] child pid 33143 exit signal Segmentation fault (11)
[Tue Jul 08 05:06:18 2014] [notice] child pid 33522 exit signal Segmentation fault (11)
[Tue Jul 08 05:06:19 2014] [notice] child pid 33534 exit signal Segmentation fault (11)
我用谷歌搜索了这个错误,发现了这个问题的不同答案,但似乎没有一个适用于我。
在尝试了最新的 Zend Server 7 之后,我设法在 Guzzle\Http\Curl\CurlMulti 中确定了问题,似乎在 curl_multi_* 操作期间发生了一些事情。我认为问题应该是 PHP 处于无限循环中,但它在 PHPUnit 下怎么能正常工作呢?它与从 CLI 运行无关,因为我只是尝试 curl 相同的 URL 并得到:
curl: (52) Empty reply from server
所以看起来问题仍然来自代码内部......
谷歌的一些帖子指出这个 curl 问题可能是因为 OSX Maverick 的 openssl 问题,但我认为我没有这个问题,因为我的 curl 可以很好地处理任何 https 请求。
我对这个问题的研究到此为止:(
aws-sdk-php 已经出很长时间了,我不相信这是 lib 的错,它会是我的机器吗?这是我的软件环境
OSX Mavericks 10.9.4
Zend Server 7 with PHP 5.5.13
curl --version
curl 7.30.0 (x86_64-apple-darwin13.0) libcurl/7.30.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz
【问题讨论】:
-
我在 AWS linux 服务器上遇到了同样的问题。
标签: php curl amazon-web-services amazon-s3 zend-framework2