【发布时间】:2012-03-07 14:49:27
【问题描述】:
在尝试访问 Amazon Cloudfront 时,我在使用 cURL 和 PHP 时遇到了奇怪的超时。这似乎会影响所有失效请求、创建分发等。cURL 要么报告接收到 0 个字节,要么报告接收到很少的字节,然后超时:
Operation timed out after 120000 milliseconds with 88 out of 619 bytes received。
延长超时设置似乎没有什么不同。
使用CURLOPT_VERBOSE 进行跟踪会产生以下输出:
* About to connect() to cloudfront.amazonaws.com port 443 (#0)
* Trying 72.21.215.67... * connected
* Connected to cloudfront.amazonaws.com (72.21.215.67) port 443 (#0)
* skipping SSL peer certificate verification
* SSL connection using SSL_RSA_WITH_RC4_128_MD5
* Server certificate:
* subject: CN=cloudfront.amazonaws.com,O=Amazon.com Inc.,L=Seattle,ST=Washington,C=US
* start date: Jul 30 00:00:00 2010 GMT
* expire date: Jul 29 23:59:59 2013 GMT
* common name: cloudfront.amazonaws.com
* issuer: CN=VeriSign Class 3 Secure Server CA - G2,OU=Terms of use at https://www.verisign.com/rpa (c)09,OU=VeriSign Trust Network,O="VeriSign, Inc.",C=US
> POST /2010-11-01/distribution/E1CIM4A92QFD98/invalidation HTTP/1.1
User-Agent: S3/php
Accept: */*
Host: cloudfront.amazonaws.com
Date: Wed, 07 Mar 2012 14:31:58 GMT
Content-Type: application/xml
Authorization: AWS ************************
Content-Length: 200
< HTTP/1.1 201 Created
< x-amzn-RequestId: 4c2d0d3f-6862-11e1-ac27-5531ac8c967f
< Location: https://cloudfront.amazonaws.com/2010-11-01/distribution/E1CIM4A92QFD98/invalidation/I35KLNROKA40FU
* Operation timed out after 120000 milliseconds with 0 bytes received
* Closing connection #0
这似乎类似于this question。但是,在我的情况下,看起来 curl 实际上确实得到了响应,但不知何故忽略了它并超时?据我所知,收到了响应(201 Created...),并且没有 SSL 错误。那么为什么 curl 会超时?
cURL 版本信息
[version_number] => 463623
[age] => 3
[features] => 1597
[ssl_version_number] => 0
[version] => 7.19.7
[host] => x86_64-unknown-linux-gnu
[ssl_version] => NSS/3.12.7.0
[libz_version] => 1.2.3
[protocols] => Array ( [0] => tftp [1] => ftp [2] => telnet [3] => dict [4] => ldap [5] => ldaps [6] => http [7] => file [8] => https [9] => ftps [10] => scp [11] => sftp )
【问题讨论】:
-
它说
Content-Type: application/xml和Content-Length: 200然后with 0 bytes received...似乎 响应标头 到了,但不是这个 200 字节的 XML 响应正文. -
尝试禁用防火墙只是为了进行测试并查看会发生什么。
-
谢谢@J.Bruni。我相信
Content-Length标头是针对请求的,如果您进一步看,服务器 (HTTP/1.1 201 Created) 会响应带有 Location 标头。with 0 bytes received正是问题所在。它确实收到了一些字节,但 curl 忽略它们并超时......没有防火墙 -
你是对的。好吧,如果我们能看到您是如何设置会话的...
-
例如
CURLOPT_FOLLOWLOCATION设置为true?