再会,
我有一个 Web 服务,它通过 PHP 向不同的外部 API 发出多个 cURL 请求,包括 panoramio.com、flickr.com、worldweatheronline.com 等。一年左右一切正常,但几周前失败的连接百分比通过了一些主机上的天空(panoramio.com 和 worldweatheronline.com 处于领先地位,分别有 6% 的失败请求)。对同一主机的直接后续请求可以以相同的概率成功或失败。
所以我试图弄清楚发生了什么以及我应该如何修复,也许是一些系统更新或更新的 PHP 版本被破坏了......
Ubuntu 12.04.4 LTS、PHP 5.5.16 和 nginx 上的 cURL 7.22.0 (php-fpm)。
cURL 选项是:连接超时 5 秒,总超时 60 秒,SSL 验证主机和对等方均被禁用,IP 解析强制为 IPv4。以下是失败请求的一些调试信息:
[url] => http://www.panoramio.com/map/get_panoramas.php?set=public&order=popularity&from=0&to=21&size=medium&minx=82.685329&miny=25.748195&maxx=82.695311&maxy=25.757185
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 5.004513
[namelookup_time] => 3.1E-5
[connect_time] => 0
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 173.194.71.141
[certinfo] => Array
(
)
[primary_port] => 80
[local_ip] =>
[local_port] => 0
)
或者:
(
[url] => http://api.worldweatheronline.com/free/v1/weather.ashx?key=API_KEY_REMOVED&format=js&q=38.25000,20.60000&num_of_days=7
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 158
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 67.623743
[namelookup_time] => 2.4E-5
[connect_time] => 1.15904
[pretransfer_time] => 1.159041
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => 0
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 46.37.171.96
[certinfo] => Array
(
)
[primary_port] => 80
[local_ip] => IP_REMOVED
[local_port] => PORT_REMOVED
)
如您所见,连接过程在不同状态下终止,但 DNS 名称始终正确解析。
任何如何调试和/或解决此问题的想法都将不胜感激,因为我不知道在哪里挖掘了:/