PHP中cURL的连接问题

时间:2014-09-02 09:48:32

标签: php curl panoramio

美好的一天,

我有一个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名称始终正确解析。

任何有关如何调试和/或解决此问题的想法都会非常感激,因为我不知道在哪里挖掘:/

0 个答案:

没有答案